changes per @arturadib's code review

This commit is contained in:
Stephen Mathieson 2013-06-12 11:23:56 -04:00
parent 0ce07eee07
commit 023962cfff
2 changed files with 13 additions and 20 deletions

View File

@ -1698,22 +1698,19 @@ function tempDir() {
if (state.tempDir)
return state.tempDir; // from cache
state.tempDir = os.tmpDir ?
// node 0.8+ has `os.tmpDir()`
os.tmpDir() :
// back-compat for older node installs
writeableDir(process.env['TMPDIR']) ||
writeableDir(process.env['TEMP']) ||
writeableDir(process.env['TMP']) ||
writeableDir(process.env['Wimp$ScrapDir']) || // RiscOS
writeableDir('C:\\TEMP') || // Windows
writeableDir('C:\\TMP') || // Windows
writeableDir('\\TEMP') || // Windows
writeableDir('\\TMP') || // Windows
writeableDir('/tmp') ||
writeableDir('/var/tmp') ||
writeableDir('/usr/tmp') ||
writeableDir('.'); // last resort
state.tempDir = writeableDir(os.tempDir && os.tempDir()) || // node 0.8+
writeableDir(process.env['TMPDIR']) ||
writeableDir(process.env['TEMP']) ||
writeableDir(process.env['TMP']) ||
writeableDir(process.env['Wimp$ScrapDir']) || // RiscOS
writeableDir('C:\\TEMP') || // Windows
writeableDir('C:\\TMP') || // Windows
writeableDir('\\TEMP') || // Windows
writeableDir('\\TMP') || // Windows
writeableDir('/tmp') ||
writeableDir('/var/tmp') ||
writeableDir('/usr/tmp') ||
writeableDir('.'); // last resort
return state.tempDir;
}

View File

@ -22,10 +22,6 @@ shell.mkdir('tmp');
//
var tmp = shell.tempdir();
// node 0.8+
if (os.tmpDir) {
assert.equal(os.tmpDir(), tmp);
}
assert.equal(shell.error(), null);
assert.equal(fs.existsSync(tmp), true);