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

TypeScript fstream.Writer函数代码示例

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

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



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

示例1: generate_mini_rt

function generate_mini_rt(grunt: IGrunt, outputFile: string, done: (status?: boolean) => void) {
  var preloadFiles: string[], i: number, file: string, vendor_dir: string,
      dirMap: {[dirName: string]: string[]} = {}, doppio_dir: string,
      i: number, file: string, fileDir: string, fileName: string;
  if (fs.existsSync(outputFile)) {
    // Nothing to do.
    return done();
  }
  grunt.config.requires('build.doppio_dir', 'build.vendor_dir');
  doppio_dir = grunt.config('build.doppio_dir');
  vendor_dir = grunt.config('build.vendor_dir');
  grunt.log.writeln("Generating file " + outputFile + "...");
  preloadFiles = fs.readFileSync('tools/preload').toString().split('\n');
  if (fs.existsSync('tools/preload-compile-extras')) {
    preloadFiles = preloadFiles.concat(fs.readFileSync('tools/preload-compile-extras').toString().split('\n'));
  }

  // Comb through preloadFiles to figure out which directories hold files we
  // care about, and what we should grab from each.
  for (i = 0; i < preloadFiles.length; i++) {
    file = preloadFiles[i];
    fileDir = path.dirname(file);
    fileName = path.basename(file);
    if (dirMap.hasOwnProperty(fileDir)) {
      dirMap[fileDir].push(fileName);
    } else {
      dirMap[fileDir] = [fileName];
    }
    // Add parent directories if not present.
    do {
      fileDir = path.dirname(fileDir);
      if (!dirMap.hasOwnProperty(fileDir)) {
        dirMap[fileDir] = [];
      }
    } while (path.resolve(fileDir) !== path.resolve('.'));
  }

  // Instead of telling fstream directly to pipe a list of files into the tar
  // file (impossible with fstreams), we use a filter on the *entire JCL
  // directory contents* to tell it which directories and files to include. :(
  fstream.Reader({path: vendor_dir, type: 'Directory', filter:
    function() {
      var relPath: string;
      if (this.type === 'File') {
        // It's a file. Get its parent directory path relative to the Doppio
        // directory, and see if it needs to be preloaded.
        relPath = path.relative(doppio_dir, path.dirname(this.path));
        return dirMap.hasOwnProperty(relPath) &&
               dirMap[relPath].indexOf(path.basename(this.path)) !== -1;
      } else {
        // Directory. Make sure it's in the index.
        relPath = path.relative(doppio_dir, this.path);
        return dirMap.hasOwnProperty(relPath);
      }
      return false;
    }
  }).pipe(tar.Pack()).pipe(fstream.Writer(outputFile)).on('close', function() { done(); });
}
开发者ID:cyy0418,项目名称:doppio,代码行数:58,代码来源:mini-rt.ts


示例2:

 response.on('end', () => {
     Debug.info('PHPStubs Download Complete');
     Debug.info(`Unzipping to ${this.getStubsDir()}`);
     fs.createReadStream(tmp)
         .pipe(unzip.Parse())
         .pipe(fstream.Writer(this.getStubsDir()));
     window.showInformationMessage('PHP Library Stubs downloaded and installed. You may need to re-index the workspace for them to work correctly.', 'Rebuild Now').then(item => {
         this.rebuildProject();
     });
 });
开发者ID:HvyIndustries,项目名称:crane,代码行数:10,代码来源:Cranefs.ts


示例3: unpackZipFile

async function unpackZipFile(archivePath: string, unpackPath: string) {
	let readStream = createReadStream(archivePath);
	let writeStream = fstream.Writer(unpackPath);

	console.log(chalk.yellow('Unpacking: ') + archivePath);
	return new Promise<void>((resolve, reject) => {
		readStream
			.pipe(unzip.Parse())
			.pipe(writeStream)
			.on('close', resolve)
			.on('error', reject);
	});
}
开发者ID:Tomdye,项目名称:dojo-cli,代码行数:13,代码来源:gitModule.ts


示例4:

	return new Promise<void>((resolve, reject) => {
		got.stream(githubArchivePath)
			.pipe(fstream.Writer(destArchivePath))
			.on('close', resolve)
			.on('error', reject);
	});
开发者ID:Tomdye,项目名称:dojo-cli,代码行数:6,代码来源:gitModule.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript ftp.connect函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs.realpathSync类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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