本文整理汇总了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;未经允许,请勿转载。 |
请发表评论