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


TypeScript child_process.ChildProcess类代码示例

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


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

示例1: Promise

    return new Promise((resolve: Function, reject: Function): void => {

        std.log('[TSC] compile => ' + path);

            let childProcess: ChildProcess = spawn('tsc', [], path);

            childProcess.stdout.on('data', (data: Buffer) => {
                std.log('[TSC] ' + data.toString());
            });

            childProcess.stderr.on('error', (data: Buffer) => {
                std.error('[TSC] ' + data.toString());
            });

            childProcess.on('error', reject);

            childProcess.on('close', (code) => {

                if (code !== 0) {
                    std.error(`[TSC] process exited with code ${code}`);
                } else {
                    std.log('[TSC] Files compiled');
                }

                resolve();
            });

    });
开发者ID:Romakita,项目名称:e2e-app,代码行数:28,代码来源:tsc.ts

示例2: resolve

    return new Promise<string>((resolve, reject) => {
        let childprocess: ChildProcess;
        try {
            childprocess = spawn('mono', ['--version'], { env: environment });
        }
        catch (e) {
            return resolve(undefined);
        }

        childprocess.on('error', function (err: any) {
            resolve(undefined);
        });

        let stdout = '';
        childprocess.stdout.on('data', (data: NodeBuffer) => {
            stdout += data.toString();
        });

        childprocess.stdout.on('close', () => {
            let match = versionRegexp.exec(stdout);

            if (match && match.length > 1) {
                resolve(match[1]);
            }
            else {
                resolve(undefined);
            }
        });
    });
开发者ID:gregg-miskelly,项目名称:omnisharp-vscode,代码行数:29,代码来源:getMonoVersion.ts

示例3: resolve

    return new Promise<boolean>((resolve, reject) => {
        let childprocess: ChildProcess;
        try {
            childprocess = spawn('mono', ['--version']);
        }
        catch (e) {
            return resolve(false);
        }

        childprocess.on('error', function (err: any) {
            resolve(false);
        });

        let stdout = '';
        childprocess.stdout.on('data', (data: NodeBuffer) => {
            stdout += data.toString();
        });

        childprocess.stdout.on('close', () => {
            let match = versionRegexp.exec(stdout),
                ret: boolean;

            if (!match) {
                ret = false;
            }
            else if (!range) {
                ret = true;
            }
            else {
                ret = satisfies(match[1], range);
            }

            resolve(ret);
        });
    });
开发者ID:peterblazejewicz,项目名称:omnisharp-vscode,代码行数:35,代码来源:launcher.ts

示例4: spawn

    return new Promise<any>((resolve: Function, reject: Function) => {
        const chromeDriver = `${ROOT}\node_modules\protractor\selenium\chromedriver_2.21.exe`;

        if(!Fs.existsSync(chromeDriver)){

            let childProcess: ChildProcess = spawn("node", [PROTRACTOR_INSTALL, "update"]);

            childProcess.stdout.on("data", (data) => {
                std.log(data.toString());
            });

            childProcess.stderr.on("data", (data) => {
                std.error('[INSTALL] '+data.toString());
            });

            childProcess.on("error", (data) => {
                std.error('[INSTALL] '+data.toString());
            });

            childProcess.on('close', resolve);

        } else {
            resolve();
        }
    });
开发者ID:Romakita,项目名称:e2e-app,代码行数:25,代码来源:protractor.ts

示例5: resolve

 return new Promise<Success | Error>(resolve => {
     const processProcessEnding = (code: number) => {
         resolve({
             success: true,
             code,
             stdout,
             stderr
         });
     };
     // If some error happens, then the "error" and "close" events happen.
     // If the process ends, then the "exit" and "close" events happen.
     // It is known that the order of events is not determined.
     let processExited = false;
     let processClosed = false;
     process.on('error', (error: any) => {
         outputChannel.appendLine(`error: error=${error}`);
         resolve({ success: false });
     });
     process.on('close', (code, signal) => {
         outputChannel.appendLine(`\nclose: code=${code}, signal=${signal}`);
         processClosed = true;
         if (processExited) {
             processProcessEnding(code);
         }
     });
     process.on('exit', (code, signal) => {
         outputChannel.appendLine(`\nexit: code=${code}, signal=${signal}`);
         processExited = true;
         if (processClosed) {
             processProcessEnding(code);
         }
     });
 });
开发者ID:KalitaAlexey,项目名称:RustyCode,代码行数:33,代码来源:OutputChannelProcess.ts

示例6: cb

  runScript(script: string, cb: {(err: Error | null, res: any)}) {
    const args = this.args.concat([script.trim()])
    const scr = this.scr = spawn(this.command, args)
    let output = {
      stdout: '',
      stderr: ''
    }
    scr.stdout.setEncoding('utf8')
    scr.stderr.setEncoding('utf8')
    scr.stdout.on('data', (d) => {
      output.stdout += d
    })
    scr.stderr.on('data', (d) => {
      output.stderr += d
    })

    scr.on('error', (err) => {
      if (this.stopped) return
      if (this.cbCalled) return
      this.cbCalled = true
      return cb(err, null)
    })
    scr.on('exit', (exitCode, signal) => {
      if (this.stopped) return
      if (this.cbCalled) return
      this.cbCalled = true
      if (exitCode !== 0) return cb(new Error(`script exited with non-zero exit code: ${exitCode} signal: ${signal}`), this.truncateOutput(output))
      cb(null, this.truncateOutput(output))
    })
  }
开发者ID:instructure,项目名称:ftl-engine,代码行数:30,代码来源:script.ts

示例7: onUpdateClick

function onUpdateClick() {
  if (serverProcess != null) return;

  refreshButton.disabled = true;
  installOrUninstallButton.disabled = true;
  updateButton.disabled = true;

  const systemId = treeView.selectedNodes[0].dataset["systemId"];
  const system = registry.systems[systemId];

  serverProcess = forkServerProcess([ "update", systemId, "--force", `--download-url=${system.downloadURL}` ]);
  progressLabel.textContent = `Running...`;

  serverProcess.on("message", onOperationProgress);
  serverProcess.on("exit", (statusCode: number) => {
    serverProcess = null;
    progressLabel.textContent = "";

    if (statusCode === 0) {
      system.localVersion =  system.version;
      updateSystemLabel(systemId);
    }

    refreshButton.disabled = false;
    onSelectionChange();
  });
}
开发者ID:saucyfai,项目名称:superpowers-app,代码行数:27,代码来源:systems.ts

示例8: runDiagnosticsWorker

function runDiagnosticsWorker(context: BuildContext) {
  if (!diagnosticsWorker) {
    const workerModule = path.join(__dirname, 'transpile-worker.js');
    diagnosticsWorker = fork(workerModule, [], { env: { FORCE_COLOR: true } });

    Logger.debug(`diagnosticsWorker created, pid: ${diagnosticsWorker.pid}`);

    diagnosticsWorker.on('error', (err: any) => {
      Logger.error(`diagnosticsWorker error, pid: ${diagnosticsWorker.pid}, error: ${err}`);
      workerEvent.emit('DiagnosticsWorkerDone');
    });

    diagnosticsWorker.on('exit', (code: number) => {
      Logger.debug(`diagnosticsWorker exited, pid: ${diagnosticsWorker.pid}`);
      diagnosticsWorker = null;
    });

    diagnosticsWorker.on('message', (msg: TranspileWorkerMessage) => {
      workerEvent.emit('DiagnosticsWorkerDone');
    });
  }

  const msg: TranspileWorkerMessage = {
    rootDir: context.rootDir,
    buildDir: context.buildDir,
    configFile: getTsConfigPath(context)
  };
  diagnosticsWorker.send(msg);
}
开发者ID:Kode-Kitchen,项目名称:ionic-app-scripts,代码行数:29,代码来源:transpile.ts

示例9: Promise

 let childPromise = new Promise((resolve, reject) => {
     child.on("error", e => result.error = e);
     child.on("exit", (exit_code: number) => {
         result.exit_code = exit_code;
         resolve();
     });
 });
开发者ID:KnisterPeter,项目名称:gerrit-vscode,代码行数:7,代码来源:exec.ts

示例10: Observable

 return new Observable((observer: Subscriber<Actions>) => {
   spawn.on("error", error => {
     // We both set the state and make it easy for us to log the error
     observer.next(
       actions.setExecutionState({
         kernelStatus: "process errored",
         kernelRef: action.payload.kernelRef
       })
     );
     observer.error({ type: "ERROR", payload: error, err: true });
     observer.complete();
   });
   spawn.on("exit", () => {
     observer.next(
       actions.setExecutionState({
         kernelStatus: "process exited",
         kernelRef: action.payload.kernelRef
       })
     );
     observer.complete();
   });
   spawn.on("disconnect", () => {
     observer.next(
       actions.setExecutionState({
         kernelStatus: "process disconnected",
         kernelRef: action.payload.kernelRef
       })
     );
     observer.complete();
   });
 });
开发者ID:nteract,项目名称:nteract,代码行数:31,代码来源:zeromq-kernels.ts


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