From 023962cfffcc7f79fd5e7156a028dcccc3b8a329 Mon Sep 17 00:00:00 2001 From: Stephen Mathieson Date: Wed, 12 Jun 2013 11:23:56 -0400 Subject: [PATCH] changes per @arturadib's code review --- shell.js | 29 +++++++++++++---------------- test/tempdir.js | 4 ---- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/shell.js b/shell.js index b829f5e..6c47d46 100644 --- a/shell.js +++ b/shell.js @@ -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; } diff --git a/test/tempdir.js b/test/tempdir.js index ebf5914..8db0fab 100644 --- a/test/tempdir.js +++ b/test/tempdir.js @@ -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);