1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add support for loading scoped node modules

Fixes #885
This commit is contained in:
Nick O'Leary 2016-05-06 10:16:41 +01:00
parent 337f5f9b98
commit 594ff8cd3d

View File

@ -102,22 +102,26 @@ function scanDirForNodesModules(dir,moduleName) {
var files = fs.readdirSync(dir);
for (var i=0;i<files.length;i++) {
var fn = files[i];
if (!isExcluded(fn) && (!moduleName || fn == moduleName)) {
var pkgfn = path.join(dir,fn,"package.json");
try {
var pkg = require(pkgfn);
if (pkg['node-red']) {
var moduleDir = path.join(dir,fn);
results.push({dir:moduleDir,package:pkg});
if (/^@/.test(fn)) {
results = results.concat(scanDirForNodesModules(path.join(dir,fn),moduleName));
} else {
if (!isExcluded(fn) && (!moduleName || fn == moduleName)) {
var pkgfn = path.join(dir,fn,"package.json");
try {
var pkg = require(pkgfn);
if (pkg['node-red']) {
var moduleDir = path.join(dir,fn);
results.push({dir:moduleDir,package:pkg});
}
} catch(err) {
if (err.code != "MODULE_NOT_FOUND") {
// TODO: handle unexpected error
}
}
} catch(err) {
if (err.code != "MODULE_NOT_FOUND") {
// TODO: handle unexpected error
if (fn == moduleName) {
break;
}
}
if (fn == moduleName) {
break;
}
}
}
} catch(err) {