Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
cli: don't print result of --eval
Browse files Browse the repository at this point in the history
Fixes #572.
  • Loading branch information
bnoordhuis committed Jul 25, 2011
1 parent 216829e commit df3a8fc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
var module = new Module('eval');
module.filename = path.join(cwd, 'eval');
module.paths = Module._nodeModulePaths(cwd);
var rv = module._compile('return eval(process._eval)', 'eval');
console.log(rv);
module._compile('eval(process._eval)', 'eval');

} else if (process.argv[1]) {
// make process.argv[1] into a full path
Expand Down
14 changes: 10 additions & 4 deletions test/simple/test-cli-eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ if (module.parent) {
process.exit(42);
}

// assert that the result of the final expression is written to stdout
child.exec(nodejs + ' --eval "1337; 42"',
// assert that nothing is written to stdout
child.exec(nodejs + ' --eval 42',
function(err, stdout, stderr) {
assert.equal(parseInt(stdout), 42);
assert.equal(stdout, '');
});

// assert that nothing is written to stdout
child.exec(nodejs + ' --eval console.log(42)',
function(err, stdout, stderr) {
assert.equal(stdout, '');
});

// assert that module loading works
Expand All @@ -50,6 +56,6 @@ child.exec(nodejs + ' --eval "require(\'./test/simple/test-cli-eval.js\')"',

// empty program should do nothing
child.exec(nodejs + ' -e ""', function(status, stdout, stderr) {
assert.equal(stdout, 'undefined\n');
assert.equal(stdout, '');
assert.equal(stderr, '');
});
4 changes: 2 additions & 2 deletions test/simple/test-eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ var exec = require('child_process').exec;
var success_count = 0;
var error_count = 0;

var cmd = [process.execPath, '-e', '"process.argv"', 'foo', 'bar'].join(' ');
var cmd = [process.execPath, '-e', '"console.error(process.argv)"', 'foo', 'bar'].join(' ');
var expected = "[ '" + process.execPath + "',\n 'foo',\n 'bar' ]\n";
var child = exec(cmd, function(err, stdout, stderr) {
if (err) {
console.log(err.toString());
++error_count;
return;
}
assert.equal(stdout, expected);
assert.equal(stderr, expected);
++success_count;
});

Expand Down

0 comments on commit df3a8fc

Please sign in to comment.