• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript archiver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中archiver的典型用法代码示例。如果您正苦于以下问题:TypeScript archiver类的具体用法?TypeScript archiver怎么用?TypeScript archiver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了archiver类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: createZip

// Create a zip file of the fixture data using the given zlib compression level.
function createZip(level: number): void {
  const output = fs.createWriteStream(`${outputFolder}/zipfs_fixtures_l${level}.zip`);
  const options = { zlib: { level: level } };
  const archive = archiver('zip', options);
  archive.on('error', (err: any) => {
    throw err;
  });
  archive.pipe(output);
  addFolder(archive, srcFolder);
  archive.finalize();
}
开发者ID:diegolameira,项目名称:codesandbox-client,代码行数:12,代码来源:make_zip_fixtures.ts


示例2: send_zip

function send_zip(path: string, name: string, res: express.Response){
	res.setHeader('Content-disposition', 'attachment; filename='+name+'.zip');
	res.setHeader('Content-type', 'application/zip');
	let archive = archiver('zip');
	archive.on('error', (e: Error) => {
		socket_manager.broadcast('report-error', e);
		res.end();
	});
	archive.pipe(res);
	archive.directory(path, name, {name: name+'.zip'});
	archive.finalize();
}
开发者ID:BelaPlatform,项目名称:Bela,代码行数:12,代码来源:RouteManager.ts


示例3: Promise

 return new Promise((resolve, reject) => {
   this.out.action.start(`Zipping export`)
   const before = Date.now()
   const archive = archiver('zip')
   archive.directory(this.exportDir, false)
   const output = fs.createWriteStream(this.exportPath)
   archive.pipe(output)
   output.on('close', () => {
     console.log(archive.pointer() + ' total bytes')
     this.out.action.stop(chalk.cyan(`${Date.now() - before}ms`))
     resolve()
   })
   archive.finalize()
 })
开发者ID:ahmb84,项目名称:prisma,代码行数:14,代码来源:Exporter.ts


示例4: archiver

 let finalBuffer = await new Promise<Buffer>((resolve, reject) => {
     let archive = archiver('zip');
     archive.on('warning', function (err: any) {
         if (err.code === 'ENOENT') {
             console.log(err);
         } else {
             // throw error
             reject(err);
         }
     });
     archive.on('data', data => buffers.push(data));
     archive.on('error', reject);
     archive.on('end', () => resolve(Buffer.concat(buffers)));
     filesToAdd.forEach(elem => archive.append(elem.content, { name: elem.path }));
     archive.finalize();
 });
开发者ID:gregg-miskelly,项目名称:omnisharp-vscode,代码行数:16,代码来源:TestZip.ts


示例5: asyncUploadWorkspaceDump

    private asyncUploadWorkspaceDump(url: string) {
        const storagePath = this.ctx.extensionContext.storagePath
        // TODO: handle multi-root workspaces
        const rootPath = vscode.workspace.rootPath
        if (storagePath === undefined || rootPath === undefined) {
            this.logError('Cannot start workspace dump b/c of workspace state:', { storagePath, rootPath })
            return
        }

        if (!fs.existsSync(storagePath)) fs.mkdirSync(storagePath)
        const outputPath = path.join(storagePath, 'workspace-dump.zip')
        if (fs.existsSync(outputPath)) fs.unlinkSync(outputPath)
        const output = fs.createWriteStream(outputPath)

        const zip = archiver('zip')
        zip.on('error', (err) => this.logError('zip error', safeError(err)))
        zip.on('warning', (err) => this.logError('zip warning', safeError(err)))
        zip.on('finish', () => {
            this.ctx.extensionOut.appendLine('zip - finished')
            fs.createReadStream(outputPath).pipe(
                request.put(url, {
                    qs: {
                        client: this.machineId,
                        project: this.projectId,
                        session: this.sessionId
                    }
                })
                    .on('error', (err) => this.logError('zip upload connection error', url, safeError(err)))
                    .on('complete', (resp) => {
                        if (!(resp.statusCode >= 200 && resp.statusCode < 300)) {
                            this.logError('zip upload http error', url, resp.statusCode, resp.body)
                        } else {
                            this.ctx.extensionOut.appendLine('zip - http upload finished')
                        }
                    })
            )
        })

        this.ctx.extensionOut.appendLine('zip - starting')
        zip.pipe(output)
        zip.glob('./**/*.{scala,sc,sbt,java}', { cwd: rootPath })
        zip.glob('./**/.dotty-ide{.json,-artifact}', { cwd: rootPath })
        zip.finalize()
    }
开发者ID:nicolasstucki,项目名称:dotty,代码行数:44,代码来源:tracer.ts


示例6: Promise

    return new Promise((resolve, reject) => {
        output.on('close', function () {
            resolve(); // the installer needs to wait for the filestream to be closed here
        });

        let archive = archiver('zip');
        archive.on('warning', function (err: any) {
            if (err.code === 'ENOENT') {
                console.log(err);
            } else {
                // throw error
                reject(err);
            }
        });

        archive.on('error', reject);
        archive.pipe(output);
        filesToAdd.forEach(elem => archive.append(elem.content, { name: elem.path }));
        archive.finalize();
    });
开发者ID:peterblazejewicz,项目名称:omnisharp-vscode,代码行数:20,代码来源:CreateTestZip.ts


示例7: zipAll

    static async zipAll(): Promise<Buffer> {
        const zipPath = path.join(__dirname, '../global_data');
        const zipFile = `${zipPath}.zip`;
        if (fs.existsSync(zipFile)) {
            fs.unlinkSync(zipFile);
        }

        const output = fs.createWriteStream(zipFile);
        const archive = archiver('zip');
        let isClose = false;

        archive.on('error', (err: Error) => {
            Log.error(`zip global data error: ${err.message}`);
        });

        output.on('close', () => { isClose = true; });
        output.on('end', () => { isClose = true; });

        archive.pipe(output);
        archive.directory(zipPath, false);
        // const folders = fs.readdirSync(zipPath);
        // folders.forEach(f => {
        //     if (fs.statSync(path.join(zipPath, f)).isDirectory) {
        //         archive.directory(path.join(zipPath, f), f);
        //     }
        // });
        await archive.finalize();

        while (!isClose) {
            await new Promise((resolve, reject) => {
                setTimeout(resolve, 100);
            });
        }

        return fs.readFileSync(zipFile);
    }
开发者ID:winken168,项目名称:Hitchhiker,代码行数:36,代码来源:script_transform.ts


示例8: cpy

(async () => {

  //------------------------------------
  utils.printTaskHeading('Clean');
  shell.rm('-rf', 'dist/tmp');
  shell.mkdir('-p', 'dist/tmp');

  //------------------------------------
  utils.printTaskHeading('Build frontend');
  shell.exec('npm run build', { cwd: 'frontend' });
  shell.cp('-r', 'frontend/build/.', 'plugins/versionpress/admin/public/gui');

  //------------------------------------
  utils.printTaskHeading('Copy files to dist/tmp');
  const filesToCopy = [
    '.',
    // everything except...
    '!vendor',
    '!tests',
    '!.idea',
    '!.gitignore',
    '!ruleset.xml',
  ];

  await cpy(filesToCopy, '../../dist/tmp', {
    cwd: 'plugins/versionpress',
    parents: true,
    dot: true,
  });

  //------------------------------------
  utils.printTaskHeading('Install production Composer dependencies');
  shell.exec('composer install -d dist/tmp --no-dev --prefer-dist --ignore-platform-reqs --optimize-autoloader');
  shell.rm('dist/tmp/composer.{json,lock}');

  //------------------------------------
  utils.printTaskHeading('Update version in plugin file');
  let version = shell.exec('git describe --tags').stdout.trim();

  const versionpressPhpPath = 'dist/tmp/versionpress.php';
  let content = await fs.readFile(versionpressPhpPath, { encoding: 'utf8' });
  content = content.replace(/^Version: (.*)$/m, 'Version: ' + version);
  await fs.writeFile(versionpressPhpPath, content, { encoding: 'utf8' });

  //------------------------------------
  utils.printTaskHeading('Produce ZIP file');
  const outFilePath = `dist/versionpress-${version}.zip`;
  const outFile = fs.createWriteStream(outFilePath);
  const archive = archiver('zip');
  archive.pipe(outFile);
  archive.directory('dist/tmp/', 'versionpress');
  await archive.finalize();

  //------------------------------------
  utils.printTaskHeading('Remove temp directory');
  shell.rm('-rf', 'dist/tmp');

  //------------------------------------
  utils.printTaskHeading('Done!');
  console.log(' ');
  console.log('Build ready: ' + chalk.white.bold.bgGreen(outFilePath));
  console.log(' ');

})();
开发者ID:OddenCreative,项目名称:versionpress,代码行数:64,代码来源:build.ts


示例9: Archiver

    readableObjectMode: true,
    writeableObjectMode: true,
    decodeStrings: true,
    encoding: 'test',
    highWaterMark: 1,
    objectmode: true,
    comment: 'test',
    forceLocalTime: true,
    forceZip64: true,
    store: true,
    zlib: {},
    gzip: true,
    gzipOptions: {},
};

Archiver('zip', options);

const archiver = Archiver.create('zip');

const writeStream = fs.createWriteStream('./archiver.d.ts');
const readStream = fs.createReadStream('./archiver.d.ts');

archiver.abort();

archiver.pipe(writeStream);
archiver.append(readStream, { name: 'archiver.d.ts' });
archiver.append(readStream, { date: '05/05/1991' });
archiver.append(readStream, { date: new Date() });
archiver.append(readStream, { mode: 1 });
archiver.append(readStream, { mode: 1, stats: new fs.Stats() });
开发者ID:DavidM77,项目名称:DefinitelyTyped,代码行数:30,代码来源:archiver-tests.ts



注:本文中的archiver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript arrify类代码示例发布时间:2022-05-28
下一篇:
TypeScript algoliasearch-helper类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap