當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。