[Pkg-javascript-commits] [grunt] 01/01: Fix: path.resolve will always return a value even if the path doesn't exists. So we have to check whether the path exists or not

Akhil Varkey akhilvarkey-guest at moszumanska.debian.org
Tue Nov 21 07:53:36 UTC 2017


This is an automated email from the git hooks/post-receive script.

akhilvarkey-guest pushed a commit to branch master
in repository grunt.

commit cab1fda897e67c4da8bc841f5cdba18a4ff1d6d7
Author: Harish.K <harish2704 at gmail.com>
Date:   Mon Nov 20 19:55:19 2017 +0000

    Fix: path.resolve will always return a value even if the path doesn't
    exists. So we have to check whether the path exists or not
---
 lib/grunt/task.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/grunt/task.js b/lib/grunt/task.js
index f31ff2e..4f8e625 100644
--- a/lib/grunt/task.js
+++ b/lib/grunt/task.js
@@ -4,6 +4,7 @@ var grunt = require('../grunt');
 
 // Nodejs libs.
 var path = require('path');
+var fs = require('fs');
 
 // Extend generic "task" util lib.
 var parent = grunt.util.task.create();
@@ -370,9 +371,9 @@ task.loadTasks = function(tasksdir) {
 
 // Load tasks and handlers from a given locally-installed Npm module (installed
 // relative to the base dir).
-task.loadNpmTasks = function(name) {
+task.loadNpmTasks = function(name, root) {
   loadTasksMessage('"' + name + '" local Npm module');
-  var root = path.resolve('node_modules');
+  root = root || [ 'node_modules', '/usr/lib/nodejs'].map( v=> path.resolve(v) ).find(fs.existsSync);
   var pkgfile = path.join(root, name, 'package.json');
   var pkg = grunt.file.exists(pkgfile) ? grunt.file.readJSON(pkgfile) : {keywords: []};
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/grunt.git



More information about the Pkg-javascript-commits mailing list