本文整理匯總了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);
});