Browse Source

os: rename tmpDir() to tmpdir() for consistency

Make the casing consistent with the other os.* functions but keep
os.tmpDir() around as an alias.
v0.9.9-release
Ben Noordhuis 12 years ago
parent
commit
3fe6aba558
  1. 2
      doc/api/os.markdown
  2. 4
      lib/os.js
  3. 8
      test/simple/test-os.js

2
doc/api/os.markdown

@ -6,7 +6,7 @@ Provides a few basic operating-system related utility functions.
Use `require('os')` to access this module. Use `require('os')` to access this module.
## os.tmpDir() ## os.tmpdir()
Returns the operating system's default directory for temp files. Returns the operating system's default directory for temp files.

4
lib/os.js

@ -41,13 +41,15 @@ exports.platform = function() {
return process.platform; return process.platform;
}; };
exports.tmpDir = function() { exports.tmpdir = function() {
return process.env.TMPDIR || return process.env.TMPDIR ||
process.env.TMP || process.env.TMP ||
process.env.TEMP || process.env.TEMP ||
(process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp'); (process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp');
}; };
exports.tmpDir = exports.tmpdir;
exports.getNetworkInterfaces = util.deprecate(function() { exports.getNetworkInterfaces = util.deprecate(function() {
return exports.networkInterfaces(); return exports.networkInterfaces();
}, 'getNetworkInterfaces is now called `os.networkInterfaces`.'); }, 'getNetworkInterfaces is now called `os.networkInterfaces`.');

8
test/simple/test-os.js

@ -31,13 +31,13 @@ process.env.TMPDIR = '/tmpdir';
process.env.TMP = '/tmp'; process.env.TMP = '/tmp';
process.env.TEMP = '/temp'; process.env.TEMP = '/temp';
var t = ( process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp' ); var t = ( process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp' );
assert.equal(os.tmpDir(), '/tmpdir'); assert.equal(os.tmpdir(), '/tmpdir');
process.env.TMPDIR = ''; process.env.TMPDIR = '';
assert.equal(os.tmpDir(), '/tmp'); assert.equal(os.tmpdir(), '/tmp');
process.env.TMP = ''; process.env.TMP = '';
assert.equal(os.tmpDir(), '/temp'); assert.equal(os.tmpdir(), '/temp');
process.env.TEMP = ''; process.env.TEMP = '';
assert.equal(os.tmpDir(), t); assert.equal(os.tmpdir(), t);
var endianness = os.endianness(); var endianness = os.endianness();
console.log('endianness = %s', endianness); console.log('endianness = %s', endianness);

Loading…
Cancel
Save