From ef24715127902833906fc43b8b4b578de04d3346 Mon Sep 17 00:00:00 2001 From: Felipe Plets Date: Fri, 9 Jun 2017 10:23:57 -0300 Subject: [PATCH] Fix _getRelativeTo _getRelativeTo was not considering only the first occurrence of the cwd option, with regex I fixed that. *My use case:* I have the location app/controller/appUser.js Loading it with consign as follows: ``` consign({cwd: 'app'}).include('controller'); ``` This would cause the _getRelativeTo to return ['/Users/myuser/project/','/controller/'] and thus to not load the controller. --- lib/consign.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/consign.js b/lib/consign.js index e25dfc5..46e4378 100644 --- a/lib/consign.js +++ b/lib/consign.js @@ -127,7 +127,10 @@ Consign.prototype._setLocations = function(parent, entity, push) { */ Consign.prototype._getRelativeTo = function(location) { - return '.' + location.split(this._options.cwd, 2)[1]; + var regexRule = this._options.cwd + '(.+)' + , regex = new RegExp(regexRule,'g') + ; + return '.' + location.split(regex, 2)[1]; }; /**