From b7a5fab35e870dd6ce8e04eab798a429027f0d11 Mon Sep 17 00:00:00 2001 From: dusura Date: Mon, 9 Oct 2017 10:23:33 +1100 Subject: [PATCH 1/2] shared dependencies --- lib/environment.js | 9 +++++---- package.json | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/environment.js b/lib/environment.js index e99adb6..3a4f7be 100644 --- a/lib/environment.js +++ b/lib/environment.js @@ -8,6 +8,7 @@ */ var _ = require("lodash"); var path = require("path"); +var findNodeModules = require("find-node-modules"); var args = require("./args"); var clone = require("./utils/clone"); var jsonParse = require("./utils/json").parse; @@ -25,8 +26,8 @@ var splitPath = function (val) { var uniqueVals = function (val, i, vals) { return vals.indexOf(val) === i; }; // Node directories. -var CWD_BIN = path.join(process.cwd(), "node_modules/.bin"); -var CWD_NODE_PATH = path.join(process.cwd(), "node_modules"); +var CWD_NODE_PATHS = findNodeModules({ cwd: process.cwd(), relative: false }); +var CWD_BINS = CWD_NODE_PATHS.map(p => path.join(p, '.bin')); /** * Environment wrapper. @@ -85,7 +86,7 @@ var Environment = module.exports = function (opts) { Environment.prototype.updatePath = function (archetypePaths) { return [] .concat(archetypePaths || []) - .concat([CWD_BIN]) + .concat(CWD_BINS || []) .concat(splitPath(this.env[ENV_PATH_NAME])) .concat(splitPath(this.env.PATH)) .filter(uniqueVals) @@ -107,7 +108,7 @@ Environment.prototype.updatePath = function (archetypePaths) { Environment.prototype.updateNodePath = function (archetypeNodePaths) { return [] .concat(archetypeNodePaths || []) - .concat([CWD_NODE_PATH]) + .concat(CWD_NODE_PATHS || []) .concat(splitPath(this.env.NODE_PATH)) .filter(uniqueVals) .join(DELIM); diff --git a/package.json b/package.json index 7dc0469..d4ed05e 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "dependencies": { "async": "^1.4.2", "chalk": "^1.1.1", + "find-node-modules": "^1.0.4", "js-yaml": "^3.4.3", "lodash": "^3.10.1", "nopt": "^3.0.6", From 85fe27d9e296d4c3d39600c0e8788056ba800b54 Mon Sep 17 00:00:00 2001 From: dusura Date: Mon, 9 Oct 2017 12:38:32 +1100 Subject: [PATCH 2/2] fixed style issues --- lib/environment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/environment.js b/lib/environment.js index 3a4f7be..0b1b86e 100644 --- a/lib/environment.js +++ b/lib/environment.js @@ -27,7 +27,7 @@ var uniqueVals = function (val, i, vals) { return vals.indexOf(val) === i; }; // Node directories. var CWD_NODE_PATHS = findNodeModules({ cwd: process.cwd(), relative: false }); -var CWD_BINS = CWD_NODE_PATHS.map(p => path.join(p, '.bin')); +var CWD_BINS = CWD_NODE_PATHS.map(function (p) { return path.join(p, ".bin"); }); /** * Environment wrapper.