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

TypeScript child_process.exec函数代码示例

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

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



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

示例1: Promise

	return new Promise((resolve): void => {
		exec("yarn --network-concurrency 1", {
			cwd: path,
			maxBuffer: 1024 * 1024 * 10,
		}, (error, stdout, stderr) => {
			if (error) {
				logger.error(
					`Failed to install "${pkg}" dependencies`,
					field("error", error),
					field("stdout", stdout),
					field("stderr", stderr),
				);
				process.exit(1);
			}

			logger.info(`Successfully grabbed \"${pkg}\" dependencies!`);
			resolve();
		});
	});
开发者ID:AhmadAlyTanany,项目名称:code-server,代码行数:19,代码来源:install-packages.ts


示例2: exportPDF

    function exportPDF(req: express.Request, res: express.Response) {

        let phantomBin = 'phantomjs', dest = 'data.' + req.query.format, file = utils.guid() + '.pdf';

        const exec = require('child_process').exec;

        if (os.platform().substr(0, 3) == 'win') {
            phantomBin = '"../node_modules/gator-web/bin/phantomjs-win"'
        }

        let reportUrl = application.current.consoleHost;

        if (utils.config.dev())
            reportUrl = application.settings.nodeUrl;

        reportUrl += '/report?format=pdf&accessToken=' + req['session'].accessToken + '&options=' + encodeURIComponent(req.query.options);

        const child = exec('cd phantomjs && ' + phantomBin + ' --ignore-ssl-errors=yes ../node_modules/gator-web/lib/renderpdf.js "' + reportUrl + '" ' + file,
            (err, stdout, stderr) => {

                if (err !== null) {
                    api.log(err, "PDF download");
                    res.end("Internal error");
                } else {
                    res.download('phantomjs/' + file, 'report.pdf', function(err) {

                        try {

                            if (err){
                                api.log(err, "PDF download");
                                res.end("Internal error");
                            } else {
                                let stat = fs.statSync('phantomjs/' + file);

                                if (stat.isFile())
                                    fs.unlink('phantomjs/' + file);
                            }
                        } catch(err) {}
                    });
                }
            }
        );
    }
开发者ID:GatorIO,项目名称:gator-web,代码行数:43,代码来源:reporting.ts


示例3: exec

        return new Promise<any>((resolve, reject) => {
            let cmd = [command].concat(args).join(' ');
            this.ui.info(`Running command \`${cmd}\``);

            let child = exec(cmd, options);

            child.stdout.on('data', (data: string) => {
                this.ui.log(data, this.ui.LOG_LEVEL.INFO);
            });

            child.stderr.on('data', (data: string) => {
                this.ui.error(data);
            });

            child.on('close', (code: string) => {
                this.ui.debug(`${command} exited with code ${code}`);
                resolve();
            });
        });
开发者ID:Platypi,项目名称:platypi-cli,代码行数:19,代码来源:processutils.ts


示例4: exec

		rawEncodingPromise = new TPromise<string>(c => {
			if (verbose) {
				console.log('Running "chcp" to detect terminal encoding...');
			}

			exec('chcp', (err, stdout, stderr) => {
				if (stdout) {
					const windowsTerminalEncodingKeys = Object.keys(windowsTerminalEncodings);
					for (let i = 0; i < windowsTerminalEncodingKeys.length; i++) {
						const key = windowsTerminalEncodingKeys[i];
						if (stdout.indexOf(key) >= 0) {
							return c(windowsTerminalEncodings[key]);
						}
					}
				}

				return c(void 0);
			});
		});
开发者ID:servicesgpr,项目名称:vscode,代码行数:19,代码来源:encoding.ts


示例5: it

 it("reviewjs build でRuby用設定ファイルを元にファイル群のコンパイルができること", () => {
     let baseDir = "test/fixture/ruby-book/";
     /* tslint:disable:no-require-imports */
     let fs = require("fs");
     /* tslint:enable:no-require-imports */
     if (fs.existsSync(baseDir + "ch01.html")) {
         fs.unlinkSync(baseDir + "ch01.html");
     }
     if (fs.existsSync(baseDir + "ch02.html")) {
         fs.unlinkSync(baseDir + "ch02.html");
     }
     assert(!fs.existsSync(baseDir + "ch01.html"));
     assert(!fs.existsSync(baseDir + "ch02.html"));
     return exec("../../../bin/reviewjs build", { cwd: baseDir })
         .then(() => {
             assert(fs.existsSync(baseDir + "ch01.html"));
             assert(fs.existsSync(baseDir + "ch02.html"));
         });
 });
开发者ID:vvakame,项目名称:review.js,代码行数:19,代码来源:cliSpec.ts


示例6: exec

 return new Promise<string>((resolve, reject) => {
     console.log(`>> ${command}`);
     exec(command, {
         encoding: "utf8",
         maxBuffer: 1024 * 1024,
     }, (error, stdout, stderr) => {
         if (stdout.length > 0) {
             console.log(stdout);
         }
         if (stderr.length > 0) {
             console.error(stderr);
         }
         if (error) {
             reject(error);
         } else {
             resolve(stdout);
         }
     });
 });
开发者ID:bitjourney,项目名称:ci-npm-update,代码行数:19,代码来源:index.ts


示例7: executeCordovaCommand

export function executeCordovaCommand(cwd: string, command: string): Q.Promise<any> {
    let deferred = Q.defer<any>();
    let cordovaCmd = os.platform() === "darwin" ? "cordova" : "cordova.cmd";
    let commandToExecute = cordovaCmd + " " + command;
    let process = child_process.exec(commandToExecute, { cwd: cwd });

    process.on("error", function (err: any): void {
        deferred.reject(err);
    });
    process.stdout.on("close", exitCode => {
        if (exitCode) {
            deferred.reject("Cordova command failed with exit code " + exitCode);
        } else {
            deferred.resolve({});
        }
    });

    return deferred.promise;
}
开发者ID:dahomost,项目名称:vscode-cordova,代码行数:19,代码来源:testUtils.ts


示例8: stop

export function stop(){
	let stopped: boolean = false;
	if (processes.run.get_status()){
		processes.run.stop();
		stopped = true;
	}
	if (processes.build.get_status()){
		processes.build.stop();
		stopped = true;
	}
	if (processes.syntax.get_status()){
		processes.syntax.stop();
		stopped = true;
	}
	if (!stopped){
		console.log('make -C '+paths.Bela+' stop');
		child_process.exec('make -C '+paths.Bela+' stop');	
	}
}
开发者ID:BelaPlatform,项目名称:Bela,代码行数:19,代码来源:ProcessManager.ts


示例9: openUrl

function openUrl(startUrl: string) {
    if (!/^[a-z0-9A-Z#=\.\-\\\/%:\?_]+$/.test(startUrl)) {
        console.error("invalid URL to open: " + startUrl)
        return
    }
    let cmds: U.Map<string> = {
        darwin: "open",
        win32: "start",
        linux: "xdg-open"
    }
    if (/^win/.test(os.platform()) && !/^[a-z0-9]+:\/\//i.test(startUrl))
        startUrl = startUrl.replace('/', '\\');
    else
        startUrl = startUrl.replace('\\', '/');

    let cmd = cmds[process.platform];
    console.log(`opening ${startUrl}`)
    child_process.exec(`${cmd} ${startUrl}`);
}
开发者ID:thomasdenney,项目名称:pxt,代码行数:19,代码来源:server.ts


示例10: callback

            (pageCount, callback) => {
                let output = BURST_FOLDER + duid.getDUID(1)[0] + '_page_%02d.pdf';
                mkdirp.sync(BURST_FOLDER); //this folder is periodically removed

                let command = OS_BATCH_RUN_PREFIX + ' pdftk ' + filepath + ' burst output ' + output;
                logging.info('Running external command: ' + command);
                child_process.exec(command, (err, stdout, stderr)=> {
                    if (err)
                        return callback(err || stderr);

                    let files = [];
                    let i = 1;
                    while (i <= pageCount) {
                        let no = ('0' + (i++).toString()).slice(-2);
                        files.push(output.replace('%02d', no));
                    }
                    callback(null, files);
                });
            }], final_callback);
开发者ID:zaksie,项目名称:gotouch,代码行数:19,代码来源:pdf.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript child_process.execFile函数代码示例发布时间:2022-05-24
下一篇:
TypeScript child-process-promise.spawn函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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