Skip to content

Commit

Permalink
os: use %SystemRoot% or %windir% in os.tmpdir()
Browse files Browse the repository at this point in the history
On Windows, respect the SystemRoot and windir environment variables,
don't default to c:\windows\temp.
  • Loading branch information
doortts authored and bnoordhuis committed Mar 28, 2013
1 parent 1f55704 commit 120e5a2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/os.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

var binding = process.binding('os');
var util = require('util');
var isWindows = process.platform === 'win32';

exports.endianness = binding.getEndianness;
exports.hostname = binding.getHostname;
Expand All @@ -42,16 +43,22 @@ exports.platform = function() {
};

exports.tmpdir = function() {
return process.env.TMPDIR ||
process.env.TMP ||
process.env.TEMP ||
(process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp');
};
if (isWindows) {
return process.env.TEMP ||
process.env.TMP ||
(process.env.SystemRoot || process.env.windir) + "\\temp";
} else {
return process.env.TMPDIR ||
process.env.TMP ||
process.env.TEMP ||
'/tmp';
}
}

exports.tmpDir = exports.tmpdir;

exports.getNetworkInterfaces = util.deprecate(function() {
return exports.networkInterfaces();
}, 'getNetworkInterfaces is now called `os.networkInterfaces`.');

exports.EOL = process.platform === 'win32' ? '\r\n' : '\n';
exports.EOL = isWindows ? '\r\n' : '\n';

0 comments on commit 120e5a2

Please sign in to comment.