From 707b5e1e4ddbc65dc9db5f963233b8460ee1c872 Mon Sep 17 00:00:00 2001 From: Richard Herrera Date: Mon, 23 Feb 2015 11:04:00 -0800 Subject: [PATCH 1/4] Avoiding hard-coded paths, default to process.env.NODE_PATH if defined. --- bin/slush.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/slush.js b/bin/slush.js index 2cfcb48..cd6b1ea 100755 --- a/bin/slush.js +++ b/bin/slush.js @@ -177,12 +177,19 @@ function getModulesPaths () { if (process.env.NODE_ENV === 'test') { return [path.join(__dirname, '..', 'test')]; } + var sep = (process.platform === 'win32') ? ';' : ':'; var paths = []; - if (process.platform === 'win32') { - paths.push(path.join(process.env.APPDATA, 'npm', 'node_modules')); + + if (process.env.NODE_PATH) { + paths = paths.concat(process.env.NODE_PATH.split(sep)); } else { - paths.push('/usr/lib/node_modules'); + if (process.platform === 'win32') { + paths.push(path.join(process.env.APPDATA, 'npm', 'node_modules')); + } else { + paths.push('/usr/lib/node_modules'); + } } + paths.push(path.join(__dirname, '..', '..')); paths.push.apply(paths, require.main.paths); return paths.map(function(path){ From eacea8eb68391eef611d567b9e9aecbf36f40144 Mon Sep 17 00:00:00 2001 From: Richard Herrera Date: Mon, 23 Feb 2015 11:05:02 -0800 Subject: [PATCH 2/4] Fix #17: Issues with OSX and case sensitive filesystem --- bin/slush.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/slush.js b/bin/slush.js index cd6b1ea..6475e08 100755 --- a/bin/slush.js +++ b/bin/slush.js @@ -192,9 +192,7 @@ function getModulesPaths () { paths.push(path.join(__dirname, '..', '..')); paths.push.apply(paths, require.main.paths); - return paths.map(function(path){ - return path.toLowerCase(); - }).filter(function(path, index, all){ + return paths.filter(function(path, index, all){ return all.lastIndexOf(path) === index; }); } From 746ee2009617bafb23451aa4f74b8b85636588fb Mon Sep 17 00:00:00 2001 From: Richard Herrera Date: Mon, 23 Feb 2015 11:06:22 -0800 Subject: [PATCH 3/4] Add support for scoped npm modules (https://www.npmjs.com/enterprise#scoped) --- bin/slush.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/slush.js b/bin/slush.js index 6475e08..1b1a538 100755 --- a/bin/slush.js +++ b/bin/slush.js @@ -199,8 +199,8 @@ function getModulesPaths () { function findGenerators (searchpaths) { return searchpaths.reduce(function (arr, searchpath) { - return arr.concat(glob.sync('slush-*', {cwd: searchpath, stat: true}).map(function (match) { - var generator = {path: path.join(searchpath, match), name: match.slice(6), pkg: {}}; + return arr.concat(glob.sync('{@*/,}slush-*', {cwd: searchpath, stat: true}).map(function (match) { + var generator = {path: path.join(searchpath, match), name: match.replace(/(?:@[\w]+[\/|\\]+)?slush-/, ""), pkg: {}}; try { generator.pkg = require(path.join(searchpath, match, 'package.json')); } catch (e) { From 8967e6b3c720163a07eed6571b45328fb784bc3f Mon Sep 17 00:00:00 2001 From: Richard Herrera Date: Mon, 23 Feb 2015 11:19:52 -0800 Subject: [PATCH 4/4] Fix failing test --- test/slush.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/slush.js b/test/slush.js index 320b3e4..c9a6a5f 100644 --- a/test/slush.js +++ b/test/slush.js @@ -25,8 +25,8 @@ describe('slush', function () { }); slush.on('close', function (code) { code.should.equal(0); - data.should.match(/\[gulp\] ├── default/); - data.should.match(/\[gulp\] └── app/); + data.should.match(/├── default/); + data.should.match(/└── app/); done(); }); });