mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 17:01:08 +00:00

Author: Benjamin Gruenbaum <inglor@gmail.com> Author: Anna Henningsen <anna@addaleax.net> PR-URL: https://github.com/nodejs/node/pull/12442 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: William Kapke <william.kapke@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
35 lines
853 B
JavaScript
35 lines
853 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const child_process = require('child_process');
|
|
const { promisify } = require('util');
|
|
|
|
common.crashOnUnhandledRejection();
|
|
|
|
const exec = promisify(child_process.exec);
|
|
const execFile = promisify(child_process.execFile);
|
|
|
|
{
|
|
exec(`${process.execPath} -p 42`).then(common.mustCall((obj) => {
|
|
assert.deepStrictEqual(obj, { stdout: '42\n', stderr: '' });
|
|
}));
|
|
}
|
|
|
|
{
|
|
execFile(process.execPath, ['-p', '42']).then(common.mustCall((obj) => {
|
|
assert.deepStrictEqual(obj, { stdout: '42\n', stderr: '' });
|
|
}));
|
|
}
|
|
|
|
{
|
|
exec('doesntexist').catch(common.mustCall((err) => {
|
|
assert(err.message.includes('doesntexist'));
|
|
}));
|
|
}
|
|
|
|
{
|
|
execFile('doesntexist', ['-p', '42']).catch(common.mustCall((err) => {
|
|
assert(err.message.includes('doesntexist'));
|
|
}));
|
|
}
|