Skip to content

use os.tmpDir #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
language: node_js
node_js:
- 0.4
- 0.6
- 0.8
22 changes: 2 additions & 20 deletions lib/tmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
var
fs = require('fs'),
path = require('path'),
os = require('os'),
exists = fs.exists || path.exists,
_c = require('constants');

Expand All @@ -18,7 +19,7 @@ var
*/
var
// store the actual TMP directory
_TMP = _getTMPDir(),
_TMP = os.tmpDir()

// the random characters to choose from
randomChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",
Expand All @@ -27,25 +28,6 @@ var
// this will hold the objects need to be removed on exit
_removeObjects = [];

/**
* 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},

"engines": {
"node": ">=0.4.0"
"node": ">=0.8.0"
},

"dependencies": {},
Expand Down