當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs-extra-promise.createWriteStream函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。