本文整理汇总了TypeScript中child_process.exec类的典型用法代码示例。如果您正苦于以下问题:TypeScript exec类的具体用法?TypeScript exec怎么用?TypeScript exec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了exec类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('handles a returned string', async () => {
const cpExec = require('child_process').exec;
cpExec.mockImplementation((_a: any, _b: any, c: any) => c(null, 'hi'));
const result = await execModule.exec('a/dir', 'echo hi');
expect(result).toBe('hi');
});
示例2: it
it('executes a given string', async () => {
const cpExec = require('child_process').exec;
cpExec.mockImplementation((_a: any, _b: any, c: any) => c(null, Buffer.from('hi')));
const result = await exec('a/dir', 'echo hi');
const call = cpExec.mock.calls[0];
expect(call[0]).toBe('echo hi');
expect(call[1]).toEqual({ cwd: 'a/dir', maxBuffer: 20480000 });
expect(result).toBe('hi');
});
示例3:
.then(function() {
const command = `node ${jsOutputFilePath}`;
logger.info({command: command}, 'Spawning node on generated js');
return q.nfcall(child_process.exec.bind(child_process), command);
})