mirror of https://github.com/lukechilds/node.git
Browse Source
The current working directory may not exist when the REPL starts up. Don't treat that as an error because it's still possible to do many useful things. This is like the previous commit but for the REPL. 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>v1.8.0-commit
Ben Noordhuis
10 years ago
2 changed files with 36 additions and 2 deletions
@ -0,0 +1,26 @@ |
|||
var common = require('../common'); |
|||
var assert = require('assert'); |
|||
var fs = require('fs'); |
|||
var spawn = require('child_process').spawn; |
|||
|
|||
// Fails with EINVAL on SmartOS, EBUSY on Windows.
|
|||
if (process.platform === 'sunos' || process.platform === 'win32') { |
|||
console.log('1..0 # Skipped: cannot rmdir current working directory'); |
|||
return; |
|||
} |
|||
|
|||
var dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid; |
|||
fs.mkdirSync(dirname); |
|||
process.chdir(dirname); |
|||
fs.rmdirSync(dirname); |
|||
|
|||
var proc = spawn(process.execPath, ['--interactive']); |
|||
proc.stdout.pipe(process.stdout); |
|||
proc.stderr.pipe(process.stderr); |
|||
proc.stdin.write('require("path");\n'); |
|||
proc.stdin.write('process.exit(42);\n'); |
|||
|
|||
proc.once('exit', common.mustCall(function(exitCode, signalCode) { |
|||
assert.equal(exitCode, 42); |
|||
assert.equal(signalCode, null); |
|||
})); |
Loading…
Reference in new issue