diff --git a/doc/api/os.markdown b/doc/api/os.markdown index 3ef0d9282d748f..ae620e895cd32f 100644 --- a/doc/api/os.markdown +++ b/doc/api/os.markdown @@ -6,7 +6,7 @@ Provides a few basic operating-system related utility functions. Use `require('os')` to access this module. -## os.tmpDir() +## os.tmpdir() Returns the operating system's default directory for temp files. diff --git a/lib/os.js b/lib/os.js index 612a0e43d503b1..673b7dd7d5e3ae 100644 --- a/lib/os.js +++ b/lib/os.js @@ -41,13 +41,15 @@ exports.platform = function() { return process.platform; }; -exports.tmpDir = function() { +exports.tmpdir = function() { return process.env.TMPDIR || process.env.TMP || process.env.TEMP || (process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp'); }; +exports.tmpDir = exports.tmpdir; + exports.getNetworkInterfaces = util.deprecate(function() { return exports.networkInterfaces(); }, 'getNetworkInterfaces is now called `os.networkInterfaces`.'); diff --git a/test/simple/test-os.js b/test/simple/test-os.js index 59278329ccf445..79de1b14a40b58 100644 --- a/test/simple/test-os.js +++ b/test/simple/test-os.js @@ -31,13 +31,13 @@ process.env.TMPDIR = '/tmpdir'; process.env.TMP = '/tmp'; process.env.TEMP = '/temp'; var t = ( process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp' ); -assert.equal(os.tmpDir(), '/tmpdir'); +assert.equal(os.tmpdir(), '/tmpdir'); process.env.TMPDIR = ''; -assert.equal(os.tmpDir(), '/tmp'); +assert.equal(os.tmpdir(), '/tmp'); process.env.TMP = ''; -assert.equal(os.tmpDir(), '/temp'); +assert.equal(os.tmpdir(), '/temp'); process.env.TEMP = ''; -assert.equal(os.tmpDir(), t); +assert.equal(os.tmpdir(), t); var endianness = os.endianness(); console.log('endianness = %s', endianness);