当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript child_process.exec函数代码示例

本文整理汇总了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;未经允许,请勿转载。