mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-18 16:03:37 +00:00
This is an issue in the case of `echo(which('fakecmd'))`. This used to succeed
in v0.6 but was broken during the ShellString refactor.
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
var shell = require('..');
|
|
|
|
var assert = require('assert'),
|
|
child = require('child_process');
|
|
|
|
shell.config.silent = true;
|
|
|
|
shell.rm('-rf', 'tmp');
|
|
shell.mkdir('tmp');
|
|
|
|
//
|
|
// Valids
|
|
//
|
|
|
|
|
|
// From here on we use child.exec() to intercept the stdout
|
|
|
|
|
|
// simple test with defaults
|
|
shell.mkdir('-p', 'tmp');
|
|
var file = 'tmp/tempscript'+Math.random()+'.js',
|
|
script = 'require(\'../../global.js\'); echo("-asdf", "111");'; // test '-' bug (see issue #20)
|
|
shell.ShellString(script).to(file);
|
|
child.exec(JSON.stringify(process.execPath)+' '+file, function(err, stdout) {
|
|
assert.equal(stdout, '-asdf 111\n');
|
|
|
|
// using null as an explicit argument doesn't crash the function
|
|
file = 'tmp/tempscript'+Math.random()+'.js';
|
|
script = 'require(\'../../global.js\'); echo(null);';
|
|
shell.ShellString(script).to(file);
|
|
child.exec(JSON.stringify(process.execPath)+' '+file, function(err, stdout, stderr) {
|
|
assert.equal(stdout, 'null\n');
|
|
assert.equal(stderr, '');
|
|
|
|
// simple test with silent(true)
|
|
shell.mkdir('-p', 'tmp');
|
|
var file = 'tmp/tempscript'+Math.random()+'.js',
|
|
script = 'require(\'../../global.js\'); config.silent=true; echo(555);';
|
|
shell.ShellString(script).to(file);
|
|
child.exec(JSON.stringify(process.execPath)+' '+file, function(err, stdout) {
|
|
assert.equal(stdout, '555\n');
|
|
|
|
theEnd();
|
|
});
|
|
});
|
|
});
|
|
|
|
function theEnd() {
|
|
shell.exit(123);
|
|
}
|