Package: grunt / 1.0.1-8+deb10u1

add-root-variable.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From bf6b918119d6fed82d4f674588f67eab394b6bf6 Mon Sep 17 00:00:00 2001
From: Maurits Lamers <maurits@weidestraat.nl>
Date: Sat, 9 Nov 2013 11:23:00 +0100
Subject: [PATCH 1/2] adding option to define root where to load npm modules
 from

with patch from Harish to load modules from /usr/lib/nodejs by default
---
 lib/grunt/task.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/lib/grunt/task.js
+++ b/lib/grunt/task.js
@@ -4,6 +4,7 @@
 
 // Nodejs libs.
 var path = require('path');
+var fs = require('fs');
 
 // Extend generic "task" util lib.
 var parent = grunt.util.task.create();
@@ -370,9 +371,10 @@
 
 // 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'].find( v => v && fs.existsSync( path.join(v, name) ) );
+  root = root || '/usr/lib/nodejs';
   var pkgfile = path.join(root, name, 'package.json');
   var pkg = grunt.file.exists(pkgfile) ? grunt.file.readJSON(pkgfile) : {keywords: []};