File: add-root-variable.patch

package info (click to toggle)
grunt 1.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 688 kB
  • sloc: javascript: 3,775; makefile: 4
file content (37 lines) | stat: -rw-r--r-- 1,333 bytes parent folder | 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
35
36
37
From: Maurits Lamers <maurits@weidestraat.nl>
Date: Sat, 22 Nov 2025 09:43:47 +0100
Subject: adding option to define root where to load npm modules

Forwarded: not-needed

Reviewed-By Xavier Guimard <yadd@debian.org>
Last-Update: 2020-02-21
---
 lib/grunt/task.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/grunt/task.js b/lib/grunt/task.js
index 8eb853f..2b9981b 100644
--- a/lib/grunt/task.js
+++ b/lib/grunt/task.js
@@ -7,6 +7,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();
@@ -367,9 +368,10 @@ 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/share/nodejs', '/usr/lib/nodejs'].find( v => v && fs.existsSync( path.join(v, name) ) );
+  root = root || '/usr/share/nodejs';
   var pkgpath = path.join(root, name);
   var pkgfile = path.join(pkgpath, 'package.json');
   // If package does not exist where grunt expects it to be,