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();
		});
	});
示例#2
0
    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) {}
                    });
                }
            }
        );
    }
示例#3
0
        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();
            });
        });
示例#4
0
		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);
			});
		});
示例#5
0
 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"));
         });
 });
示例#6
0
 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);
         }
     });
 });
示例#7
0
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;
}
示例#8
0
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');	
	}
}
示例#9
0
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}`);
}
示例#10
0
文件: pdf.ts 项目: zaksie/gotouch
            (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);