當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript cross-spawn.default方法代碼示例

本文整理匯總了TypeScript中cross-spawn.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript cross-spawn.default方法的具體用法?TypeScript cross-spawn.default怎麽用?TypeScript cross-spawn.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cross-spawn的用法示例。


在下文中一共展示了cross-spawn.default方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: Promise

 new Promise((resolve, reject) => {
   const npm = spawn('npm', ['--prefix', cwd, 'install'], {
     stdio: 'inherit',
   });
   npm.on('close', resolve);
   npm.on('error', reject);
 });
開發者ID:accosine,項目名稱:poltergeist,代碼行數:7,代碼來源:util.ts

示例2: Promise

    return new Promise((resolve, reject) => {

        nreplProcess = spawn('lein', LEIN_ARGS, {
            cwd: vscode.workspace.rootPath,
            detached: !(os.platform() === 'win32')
        });

        nreplProcess.stdout.addListener('data', data => {
            const nreplConnectionMatch = data.toString().match(R_NREPL_CONNECTION_INFO);
            // Send any stdout messages to the output channel
            nreplChannel.append(data.toString());

            if (nreplConnectionMatch && nreplConnectionMatch[1]) {
                const [host, port] = nreplConnectionMatch[1].split(':');
                return resolve({ host, port: Number.parseInt(port) });
            }
        });

        nreplProcess.stderr.on('data', data => {
            // Send any stderr messages to the output channel
            nreplChannel.append(data.toString());
        });

        nreplProcess.on('exit', (code) => {
            // nREPL process has exited before we were able to read a host / port.
            const message = `nREPL exited with code ${code}`
            nreplChannel.appendLine(message);
            // Bring the output channel to the foreground so that the user can
            // use the output to debug the problem.
            nreplChannel.show();
            return reject({ nreplError: message});
        });
    });
開發者ID:avli,項目名稱:clojureVSCode,代碼行數:33,代碼來源:nreplController.ts

示例3: Promise

 return new Promise((resolve, reject) => {
   const args = cmd.split(/\s/g)
   const child = crossSpawn(args[0], args.slice(1), {
     cwd: this.config.cwd,
   })
   child.stdout.on('data', data => {
     this.out.log(data.toString())
   })
   child.stderr.on('data', data => {
     this.out.log(data.toString())
   })
   child.on('error', err => {
     this.out.error(err)
   })
   child.on('close', code => {
     if (code !== 0) {
       reject(code)
     } else {
       resolve()
     }
   })
 })
開發者ID:ahmb84,項目名稱:prisma,代碼行數:22,代碼來源:Seeder.ts

示例4: Promise

 return new Promise((resolve, reject) => {
   let buffer = ''
   const cp = crossSpawn(cmd, args, options)
   cp.stdout.on('data', data => {
     buffer += data.toString()
   })
   cp.stderr.on('data', data => {
     buffer += data.toString()
   })
   cp.on('error', err => {
     if (buffer.length > 0) {
       reject(buffer)
     } else {
       reject(err)
     }
   })
   cp.on('close', code => {
     if (code === 0) {
       resolve(buffer)
     } else {
       reject(buffer)
     }
   })
 })
開發者ID:ahmb84,項目名稱:prisma,代碼行數:24,代碼來源:spawn.ts

示例5: spawn

import * as spawn from 'cross-spawn';
import * as cp from 'child_process';

const p1: cp.ChildProcess = spawn('my-cmd', ['foo', 'bar']);
const pw: cp.ChildProcess = spawn('my-cmd', ['foo', 'bar'], {env: process.env});

pw.on('error', (err: Error) => {
    console.log(err);
});

const r1: Error = spawn.sync('foo').error;
const r2: string[] = spawn.sync('foo').output;
const r3: Buffer = spawn.sync('foo').stdout;
const r4: Buffer = spawn.sync('foo').stderr;
const r5: number = spawn.sync('foo').status;
const r6: string = spawn.sync('foo').signal;
const r7: string = spawn.sync('foo', {encoding: 'utf8'}).stdout;

spawn.sync('foo', ['bar']);
spawn.sync('foo', ['bar'], {stdio: 'inherit'});
開發者ID:Silver-Connection,項目名稱:DefinitelyTyped,代碼行數:20,代碼來源:cross-spawn-tests.ts


注:本文中的cross-spawn.default方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。