Permalink
Browse files

windows: use USERPROFILE to get the user's home dir

Fixes GH-3461
Fixes GH-3462
  • Loading branch information...
1 parent 76ddf06 commit f9a5a917f4a7d9e0fa69a1e26126c19ff59fd44d @piscisaureus piscisaureus committed Oct 7, 2012
Showing with 13 additions and 5 deletions.
  1. +13 −5 lib/module.js
View
@@ -497,16 +497,24 @@ Module.runMain = function() {
Module._load(process.argv[1], null, true);
};
-Module._initPaths = function() {
+Module._initPaths = function () {
+ var isWindows = process.platform === 'win32';
+
+ if (!isWindows) {
@bnoordhuis

bnoordhuis Oct 8, 2012

Owner

Maybe swap the if/else clauses, if (isWindows) is easier to read than if (!isWindows). Otherwise LGTM.

+ var homeDir = process.env.HOME;
+ } else {
+ var homeDir = process.env.USERPROFILE;
+ }
+
var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')];
- if (process.env['HOME']) {
- paths.unshift(path.resolve(process.env['HOME'], '.node_libraries'));
- paths.unshift(path.resolve(process.env['HOME'], '.node_modules'));
+ if (homeDir) {
+ paths.unshift(path.resolve(homeDir, '.node_libraries'));
+ paths.unshift(path.resolve(homeDir, '.node_modules'));
}
if (process.env['NODE_PATH']) {
- var splitter = process.platform === 'win32' ? ';' : ':';
+ var splitter = isWindows ? ';' : ':';
paths = process.env['NODE_PATH'].split(splitter).concat(paths);
}

1 comment on commit f9a5a91

isaacs commented on f9a5a91 Oct 8, 2012

Ugh. ~/.node_libraries was such a mistake. This makes me sad, but the people have spoken, I suppose.

LGTM.

Please sign in to comment.