• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript tmp.file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中tmp.file函数的典型用法代码示例。如果您正苦于以下问题:TypeScript file函数的具体用法?TypeScript file怎么用?TypeScript file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了file函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

 tmp.file({prefix: 'nez', postfix: '.p4d'}, function(p4d_err,p4d_tempfile,fd) {
   if(p4d_err) {
       console.log(p4d_err);
       return;
   }
   tmp.file({prefix: 'nez'}, function(src_err,src_tempfile,fd) {
   if(src_err) {
       console.log(src_err);
       return;
   }
   var dest_file = src_tempfile + '_rev.txt'
   var exec_command = nez_command + ' -p ' + p4d_tempfile + ' -t json -i ' + src_tempfile + ' > ' + dest_file;
     console.log(exec_command);
     createFileAndExec(src_tempfile, req.body.source, p4d_tempfile, req.body.p4d, exec_command, function(stdout) {
         var data = fs.readFileSync(dest_file);
         if(data.length > 0) {
             var sendData:any = /(^{$|\n{\n)[\S\s]*/m.exec(data.toString());
             if(sendData){
               var j = { source: sendData[0], runnable: true };
             } else {
               var j = { source: data.toString(), runnable: false };
             }
               genResponse(res, j);
         } else {
             var msg = "エラー訂正候補を出せませんでした";
             var error_j = { source: msg, runnable: false };
             genResponse(res, error_j);
         }
     });
   });
 });
开发者ID:nikuuchi,项目名称:nez-web,代码行数:31,代码来源:post.ts


示例2: reject

 .then(inStream => {
     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,代码行数:33,代码来源:download.ts


示例3: _tempFileCreated

 return new Promise<string>((resolve, reject) => {
     tmp.file({ prefix: 'vscode-restclient-', postfix: ".http" }, function _tempFileCreated(err, tmpFilePath, fd) {
         if (err) {
             reject(err);
             return;
         }
         let output = `${request.method.toUpperCase()} ${request.url}${EOL}`;
         if (request.headers) {
             for (let header in request.headers) {
                 if (request.headers.hasOwnProperty(header)) {
                     let value = request.headers[header];
                     output += `${header}: ${value}${EOL}`;
                 }
             }
         }
         if (request.body) {
             output += `${EOL}${request.body}`;
         }
         fs.writeFile(tmpFilePath, output, error => {
             reject(error);
             return;
         });
         resolve(tmpFilePath);
     });
 });
开发者ID:Huachao,项目名称:vscode-restclient,代码行数:25,代码来源:historyController.ts


示例4: async

 return new Promise<void>((resolve, reject) => {
     tmp.file({postfix: '.vsix'}, async (err, vsixPath, fd, cleanupCallback) => {
         if (err) {
             reject(new Error('Failed to create vsix file'));
             return;
         }
 
         // Place in try/catch as the .catch call catches a rejection in downloadFileToDestination
         // then the .catch call will return a resolved promise
         // Thusly, the .catch call must also throw, as a return would simply return an unused promise
         // instead of returning early from this function scope
         let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration();
         let originalProxySupport: string = config.inspect<string>('http.proxySupport').globalValue;
         while (true) { // Might need to try again with a different http.proxySupport setting.
             try {
                 await util.downloadFileToDestination(buildInfo.downloadUrl, vsixPath);
             } catch {
                 // Try again with the proxySupport to "off".
                 if (originalProxySupport !== config.inspect<string>('http.proxySupport').globalValue) {
                     config.update('http.proxySupport', originalProxySupport, true); // Reset the http.proxySupport.
                     reject(new Error('Failed to download VSIX package with proxySupport off')); // Changing the proxySupport didn't help.
                     return;
                 }
                 if (config.get('http.proxySupport') !== "off" && originalProxySupport !== "off") {
                     config.update('http.proxySupport', "off", true);
                     continue;
                 }
                 reject(new Error('Failed to download VSIX package'));
                 return;
             }
             if (originalProxySupport !== config.inspect<string>('http.proxySupport').globalValue) {
                 config.update('http.proxySupport', originalProxySupport, true); // Reset the http.proxySupport.
                 telemetry.logLanguageServerEvent('installVsix', { 'error': "Success with proxySupport off", 'success': 'true' });
             }
             break;
         }
         try {
             await installVsix(vsixPath);
         } catch (error) {
             reject(error);
             return;
         }
         clearInterval(insiderUpdateTimer);
         const message: string =
             `The C/C++ Extension has been updated to version ${buildInfo.name}. Please reload the window for the changes to take effect.`;
         util.promptReloadWindow(message);
         telemetry.logLanguageServerEvent('installVsix', { 'success': 'true' });
         resolve();
     });
 }).catch(error => {
开发者ID:swyphcosmo,项目名称:vscode-cpptools,代码行数:50,代码来源:extension.ts


示例5: reject

  return new Promise<string>((resolve, reject) => {
    tmp.file(
        {mode: 0b111000000, prefix: opt.prefix, postfix: opt.postfix},
        (err, fpath, fd) => {
          if (err) {
            reject(err);
            return;
          }
          try {
            const ostream = fs.createWriteStream(fpath, {fd});
            const req = https.get(url, res => {
              if (res.statusCode !== 200) {
                reject(new Error('Non-200 response when downloading new CMake installer'));
                return;
              }

              let totalSize: number = 0;
              try {
                totalSize = parseInt(res.headers['content-length'] || '0');
              } catch (e) {
                // Do nothing. Oh well.
              }

              let prevDownloaded = 0;
              let totalDownloaded = 0;
              res.on('data', data => {
                totalDownloaded = totalDownloaded + data.length;
                if (totalSize !== 0) {
                  const diffPercent = 100 * (totalDownloaded - prevDownloaded) / totalSize;
                  const totalPercent = 100 * totalDownloaded / totalSize;
                  if (diffPercent > 1) {
                    pr.report({
                      increment: diffPercent,
                      message: `${totalPercent.toFixed(0)}%`,
                    });
                    prevDownloaded = totalDownloaded;
                  }
                }
              });
              res.pipe(ostream);
              res.on('end', () => {
                log.info(`Downloaded ${url} to ${fpath}`);
                resolve(fpath);
              });
            });
            req.on('error', e => reject(e));
          } catch (e) { reject(e); }
        },
    );
  });
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:50,代码来源:cm-upgrade.ts


示例6: reject

            repo.downloadAsset(foundAsset, (err, inStream) => {
                if (err) {
                    return reject(err);
                }
                
                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,代码行数:49,代码来源:omnisharpDownload.ts


示例7: installFailed

            .then((res) => {
                loader.update('Saving installer...');
                tmp.file((err, path, fd, cleanupCallback) => {
                    if (err) {
                        console.error(err);
                        installFailed();
                        return;
                    }

                    fs.write(fd, res.data, 0, 'utf8', (err) => {
                        if (err) {
                            console.error(err);
                            installFailed();
                            return;
                        }

                        console.log(`written to: ${path}`);
                        loader.update('Running installer...', true);

                        this.Runner.runCommandAsync('python', path)
                            .then((out) => {
                                console.log(out);
                                remote.dialog.showMessageBox({
                                    type: 'info',
                                    title: 'Installation successful',
                                    message: 'PIP was successfully installed.',
                                    buttons: ['OK']
                                });
                            }, (out) => {
                                console.error('Failed...', out);
                                installFailed();
                            })
                            .finally(() => {
                                loader.done();
                                cleanupCallback();
                                this.$state.reload();
                            });
                    });
                });
            }, (res) => {
开发者ID:rose-m,项目名称:oSeed,代码行数:40,代码来源:ctrl.ts


示例8: download

		return download(SERVER_ARCHIVE, proxy, strictSSL).then(is => {
			tmp.file((err, tmpPath, fd, cleanupCallback) => {
				const out = fs.createWriteStream(null, { fd: fd });
				// handle errors 
				out.once('error', err => {
					closeDownloadProgressItem();
					reject(err);
				});
				is.once('error', err => {
					closeDownloadProgressItem();
					reject(err);
				});
				out.once('finish', () => {
					decompress(tmpPath, SERVER_FOLDER).then(files => {
						closeDownloadProgressItem();
						return resolve(true);
					}).catch(err => {
						closeDownloadProgressItem();
						return reject(err);
					});
				});
				is.pipe(out);
			});
		}).catch(err => {
开发者ID:silverbulleters,项目名称:vsc-spellchecker,代码行数:24,代码来源:downloadManager.ts


示例9:

	const [path, cleanup] = await new Promise<[string, any]>((res, rej) => {
		tmp.file((e, path, fd, cleanup) => {
			if (e) return rej(e);
			res([path, cleanup]);
		});
	});
开发者ID:ha-dai,项目名称:Misskey,代码行数:6,代码来源:upload-from-url.ts



注:本文中的tmp.file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript tmp.fileSync函数代码示例发布时间:2022-05-25
下一篇:
TypeScript tmp.dirSync函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap