Skip to content

Commit

Permalink
fix #51, npm-cache throws when being run from exec
Browse files Browse the repository at this point in the history
  • Loading branch information
swarajban committed Apr 28, 2016
1 parent 49222bc commit 0470c2f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,18 @@ var main = function () {
.callback(reportHash)
.help('reports the current working hash');

var defaultCacheDirectory = process.env.NPM_CACHE_DIR;
if (defaultCacheDirectory === undefined) {
var homeDirectory = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
if (homeDirectory !== undefined) {
defaultCacheDirectory = path.resolve(homeDirectory, '.package_cache');
} else {
defaultCacheDirectory = path.resolve('/tmp', '.package_cache');
}
}

parser.option('cacheDirectory', {
default: process.env.NPM_CACHE_DIR || path.resolve(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE, '.package_cache'),
default: defaultCacheDirectory,
abbr: 'c',
help: 'directory where dependencies will be cached'
});
Expand Down

0 comments on commit 0470c2f

Please sign in to comment.