本文整理汇总了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);
});
示例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);
});