本文整理汇总了TypeScript中fs-extra-promise.createWriteStream函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createWriteStream函数的具体用法?TypeScript createWriteStream怎么用?TypeScript createWriteStream使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createWriteStream函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: reject
tmp.file((err, tmpPath, fd, cleanupCallback) => {
if (err) {
return reject(err);
}
log(`[INFO] Downloading to ${tmpPath}...`);
const outStream = fs.createWriteStream(null, { fd: fd });
outStream.once('error', err => reject(err));
inStream.once('error', err => reject(err));
outStream.once('finish', () => {
// At this point, the asset has finished downloading.
log(`[INFO] Download complete!`);
log(`[INFO] Decompressing...`);
return decompress(tmpPath, installDirectory)
.then(files => {
log(`[INFO] Done! ${files.length} files unpacked.`);
return resolve(true);
})
.catch(err => {
log(`[ERROR] ${err}`);
return reject(err);
});
});
inStream.pipe(outStream);
});
开发者ID:Firaenix,项目名称:omnisharp-vscode,代码行数:31,代码来源:download.ts
示例2: reject
tmp.file((err, tmpPath, fd, cleanupCallback) => {
if (err) {
return reject(err);
}
console.log(`[OmniSharp] Downloading to ${tmpPath}...`);
const outStream = fs.createWriteStream(null, { fd: fd });
outStream.once('error', err => reject(err));
inStream.once('error', err => reject(err));
outStream.once('finish', () => {
// At this point, the asset has finished downloading.
console.log(`[OmniSharp] Download complete!`);
let decompress = new Decompress()
.src(tmpPath)
.dest(DefaultInstallLocation);
if (path.extname(foundAsset.name).toLowerCase() === '.zip') {
decompress = decompress.use(Decompress.zip());
console.log(`[OmniSharp] Unzipping...`);
}
else {
decompress = decompress.use(Decompress.targz());
console.log(`[OmniSharp] Untaring...`);
}
decompress.run((err, files) => {
if (err) {
return reject(err);
}
console.log(`[OmniSharp] Done! ${files.length} files unpacked.`)
return resolve(true);
});
});
inStream.pipe(outStream);
});
开发者ID:Jeffiy,项目名称:omnisharp-vscode,代码行数:43,代码来源:omnisharpDownload.ts
注:本文中的fs-extra-promise.createWriteStream函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论