The current working directory may not exist when iojs starts up. Don't treat that as an error because it's still possible to do many useful things, like evaluating a command line script or starting a REPL. This commit also fixes an age-old Windows bug where process.argv[0] was not properly expanded, that's why the parallel/test-process-argv-0 test gets an update as well. Fixes: https://github.com/iojs/io.js/issues/1184 PR-URL: https://github.com/iojs/io.js/pull/1194 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Rod Vagg <rod@vagg.org>
30 lines
800 B
JavaScript
30 lines
800 B
JavaScript
var util = require('util');
|
|
var path = require('path');
|
|
var assert = require('assert');
|
|
var spawn = require('child_process').spawn;
|
|
var common = require('../common');
|
|
|
|
console.error('argv=%j', process.argv);
|
|
console.error('exec=%j', process.execPath);
|
|
|
|
if (process.argv[2] !== "child") {
|
|
var child = spawn('./iojs', [__filename, "child"], {
|
|
cwd: path.dirname(process.execPath)
|
|
});
|
|
|
|
var childArgv0 = '';
|
|
var childErr = '';
|
|
child.stdout.on('data', function(chunk) {
|
|
childArgv0 += chunk;
|
|
});
|
|
child.stderr.on('data', function(chunk) {
|
|
childErr += chunk;
|
|
});
|
|
child.on('exit', function () {
|
|
console.error('CHILD: %s', childErr.trim().split('\n').join('\nCHILD: '));
|
|
assert.equal(childArgv0, process.execPath);
|
|
});
|
|
}
|
|
else {
|
|
process.stdout.write(process.argv[0]);
|
|
}
|