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


TypeScript child-process-promise.spawn函数代码示例

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


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

示例1: Error

  }, (progress) => {

    const coursierPromise =
      cpp.spawn("java", [
        "-jar", coursierPath,
        "fetch",
        "-p",
        artifact
      ])
    const coursierProc = coursierPromise.childProcess

    let classPath = ""

    coursierProc.stdout.on('data', (data: Buffer) => {
      classPath += data.toString().trim()
    })
    coursierProc.stderr.on('data', (data: Buffer) => {
      let msg = data.toString()
      outputChannel.append(msg)
    })

    coursierProc.on('close', (code: number) => {
      if (code != 0) {
        let msg = "Fetching the language server failed."
        outputChannel.append(msg)
        throw new Error(msg)
      }

      run({
        command: "java",
        args: ["-classpath", classPath, "dotty.tools.languageserver.Main", "-stdio"]
      })
    })
    return coursierPromise
  })
开发者ID:joan38,项目名称:dotty,代码行数:35,代码来源:extension.ts

示例2: execAsync

    static async execAsync(command: string, args: Array<string>, workDir = null): Promise<void> {
        Guard.argumentNotNullOrEmpty(command, "command");
        Guard.argumentNotNull(args, "args");

        let cwd = process.cwd();
        if (workDir) {
            if (!path.isAbsolute(workDir)) {
                workDir = path.join(cwd, workDir);
            }
            if (!fs.existsSync(workDir)) {
                throw new Error(`Can't find ${workDir}.`);
            }

            process.chdir(workDir);
        }

        let promise = cp.spawn(command, args);
        let childProcess = promise.childProcess;
        childProcess.stdout.on("data", (data) => {
            process.stdout.write(data.toString());
        });
        childProcess.stderr.on("data", (data) => {
            process.stderr.write(data.toString());
        })
        return promise.then(() => {
            process.chdir(cwd);
        });
    }
开发者ID:928PJY,项目名称:docfx,代码行数:28,代码来源:common.ts

示例3: runBuildTask

async function runBuildTask({ pkgName, cmd, args, env = {} }: BuildTaskArgs) {
  const promise = spawn(cmd, args, {
    cwd: path.join(__dirname, '..'),
    env: {
      ...process.env,
      ...env
    }
  });
  const { childProcess } = promise;

  childProcess.stdout.on('data', data => {
    stdout.write(data);
  });

  childProcess.stderr.on('data', data => {
    stderr.write(data);
  });

  childProcess.on('close', code => {
    if (code) {
      stderr.write(error(`${chalk.bold(pkgName)}\n`));
    } else {
      stdout.write(done(`${chalk.bold(pkgName)}\n`));
    }
  });

  return promise;
}
开发者ID:skidding,项目名称:cosmos,代码行数:28,代码来源:build.ts

示例4: Error

    }, (progress) => {
      const args = [
        "-jar", coursierPath,
        "fetch",
        "-p",
        artifact
      ].concat(extra)
      const coursierPromise = cpp.spawn("java", args)
      const coursierProc = coursierPromise.childProcess

      let classPath = ""

      coursierProc.stdout.on('data', (data: Buffer) => {
        classPath += data.toString().trim()
      })
      coursierProc.stderr.on('data', (data: Buffer) => {
        let msg = data.toString().trim()
        outputChannel.appendLine(msg)
      })

      coursierProc.on('close', (code: number) => {
        if (code != 0) {
          let msg = `Couldn't fetch '${ artifact }' (exit code ${ code }).`
          outputChannel.appendLine(msg)
          throw new Error(msg)
        }
      })
      return coursierPromise.then(() => { return classPath })
    })
开发者ID:olafurpg,项目名称:dotty,代码行数:29,代码来源:extension.ts

示例5: build

 build() {
   return spawn('node', [
     `${path.resolve(__dirname, 'child_proc.js')}`,
     `--sourceHtml=${path.resolve(this.inputPaths[0], this.indexPath)}`,
     `--optionsPath=${path.resolve(this.inputPaths[0], this.appShellPath)}`,
     `--outputIndexPath=${path.resolve(this.outputPath, this.indexPath)}`
   ]);
 }
开发者ID:ManuCutillas,项目名称:universal,代码行数:8,代码来源:prerender.ts


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