当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript tar.x函数代码示例

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


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

示例1: streamFrintExampleToDir

 function streamFrintExampleToDir() {
   request('https://codeload.github.com/frintjs/frint/tar.gz/master')
     .on('error', deps.console.error)
     .pipe(tar.x({
       C: dir,
       filter: path => path.indexOf(`frint-master/examples/${example}/`) === 0,
       strip: 3,
     }))
     .on('error', deps.console.error)
     .on('finish', () => deps.console.log('Done!'));
 }
开发者ID:Travix-International,项目名称:frint,代码行数:11,代码来源:init.ts

示例2: Promise

 return new Promise((resolve, reject) => {
   request(`https://codeload.github.com/${ctx.org}/${ctx.repo}/tar.gz/${ctx.branch}`)
     .on('error', reject)
     .pipe(tar.x({
       C: ctx.outputDir,
       filter: p => p.indexOf(`${ctx.repo}-${ctx.branch}/${ctx.examplePath}/`) === 0,
       strip: 3,
     }))
     .on('error', reject)
     .on('finish', () => resolve(ctx));
 });
开发者ID:Travix-International,项目名称:frint,代码行数:11,代码来源:new.ts

示例3: async

export const extractArchive = async (archive: Buffer, destination: string): Promise<string[]> => {
  try {
    if (!fse.existsSync(destination)) {
      fse.mkdirSync(destination)
    }
    const buffStream = new stream.PassThrough()
    const tarWriteStream = tar.x({ sync: true, strict: true, cwd: destination })

    buffStream.end(archive)
    buffStream.pipe(tarWriteStream)

    await new Promise((resolve, reject) => {
      tarWriteStream.on('end', resolve)
      tarWriteStream.on('error', reject)
    })

    const files = await Promise.fromCallback<string[]>(cb => glob('**/*.*', { cwd: destination }, cb))
    return files.map(filePath => forceForwardSlashes(filePath))
  } catch (err) {
    throw new VError(err, `[Archive] Error extracting archive to "${destination}"`)
  }
}
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:22,代码来源:archive.ts

示例4: reject

		return new Promise<void>((resolve, reject) => {
			this.$logger.trace(`Calling pacoteService.extractPackage for packageName: '${packageName}', destinationDir: '${destinationDirectory}' and options: ${options}`);

			const source = pacote.tarball.stream(packageName, pacoteOptions);
			source.on("error", (err: Error) => {
				this.$logger.trace(`Error in source while trying to extract stream from ${packageName}. Error is ${err}`);
				reject(err);
			});

			this.$logger.trace(`Creating extract tar stream with options: ${JSON.stringify(extractOptions, null, 2)}`);
			const destination = tar.x(extractOptions);
			source.pipe(destination);

			destination.on("error", (err: Error) => {
				this.$logger.trace(`Error in destination while trying to extract stream from ${packageName}. Error is ${err}`);
				reject(err);
			});

			destination.on("finish", () => {
				this.$logger.trace(`Successfully extracted '${packageName}' to ${destinationDirectory}`);
				resolve();
			});
		});
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:23,代码来源:pacote-service.ts


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