Skip to content

Commit

Permalink
use os.tmpdir() polyfill for more consistent behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
István Karaszi committed May 11, 2015
1 parent 9bc9f93 commit a832a2a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
21 changes: 1 addition & 20 deletions lib/tmp.js
Expand Up @@ -16,7 +16,7 @@ var
crypto = require('crypto'),
exists = fs.exists || path.exists,
existsSync = fs.existsSync || path.existsSync,
tmpDir = os.tmpDir || _getTMPDir,
tmpDir = require('os-tmpdir'),
_c = require('constants');


Expand Down Expand Up @@ -72,25 +72,6 @@ function _randomChars(howMany) {
return value.join('');
}

/**
* Gets the temp directory.
*
* @return {String}
* @api private
*/
function _getTMPDir() {
var tmpNames = ['TMPDIR', 'TMP', 'TEMP'];

for (var i = 0, length = tmpNames.length; i < length; i++) {
if (_isUndefined(process.env[tmpNames[i]])) continue;

return process.env[tmpNames[i]];
}

// fallback to the default
return '/tmp';
}

/**
* Checks whether the `obj` parameter is defined or not.
*
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -33,7 +33,9 @@
"node": ">=0.4.0"
},

"dependencies": {},
"dependencies": {
"os-tmpdir": "~1.0.0"
},

"devDependencies": {
"vows": "~0.7.0"
Expand Down

0 comments on commit a832a2a

Please sign in to comment.