本文整理汇总了TypeScript中cross-spawn类的典型用法代码示例。如果您正苦于以下问题:TypeScript cross-spawn类的具体用法?TypeScript cross-spawn怎么用?TypeScript cross-spawn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了cross-spawn类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: 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
示例2: 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
示例3: 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
示例4: 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
示例5: 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
注:本文中的cross-spawn类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论