mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge branch 'dev' into repackage
This commit is contained in:
commit
51373f59e2
31
packages/node_modules/@node-red/registry/lib/localfilesystem.js
generated
vendored
31
packages/node_modules/@node-red/registry/lib/localfilesystem.js
generated
vendored
@ -20,7 +20,8 @@ var path = require("path");
|
||||
var events;
|
||||
var log;
|
||||
|
||||
var i18n = require("@node-red/util").i18n; // TODO: separate module
|
||||
var log = require("@node-red/util").log;
|
||||
var i18n = require("@node-red/util").i18n;
|
||||
|
||||
var settings;
|
||||
var disableNodePathScan = false;
|
||||
@ -29,7 +30,6 @@ var iconFileExtensions = [".png", ".gif", ".svg"];
|
||||
function init(runtime) {
|
||||
settings = runtime.settings;
|
||||
events = runtime.events;
|
||||
log = runtime.log;
|
||||
}
|
||||
|
||||
function isIncluded(name) {
|
||||
@ -289,6 +289,33 @@ function getNodeFiles(disableNodePathScan) {
|
||||
|
||||
if (!disableNodePathScan) {
|
||||
var moduleFiles = scanTreeForNodesModules();
|
||||
|
||||
// Filter the module list to ignore global modules
|
||||
// that have also been installed locally - allowing the user to
|
||||
// update a module they may not otherwise be able to touch
|
||||
|
||||
moduleFiles.sort(function(A,B) {
|
||||
if (A.local && !B.local) {
|
||||
return -1
|
||||
} else if (!A.local && B.local) {
|
||||
return 1
|
||||
}
|
||||
return 0;
|
||||
})
|
||||
var knownModules = {};
|
||||
moduleFiles = moduleFiles.filter(function(mod) {
|
||||
var result;
|
||||
if (!knownModules[mod.package.name]) {
|
||||
knownModules[mod.package.name] = true;
|
||||
result = true;
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
log.debug("Module: "+mod.package.name+" "+mod.package.version+(result?"":" *ignored due to local copy*"));
|
||||
log.debug(" "+mod.dir);
|
||||
return result;
|
||||
});
|
||||
|
||||
moduleFiles.forEach(function(moduleFile) {
|
||||
var nodeModuleFiles = getModuleNodeFiles(moduleFile);
|
||||
nodeList[moduleFile.package.name] = {
|
||||
|
@ -111,7 +111,6 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
});
|
||||
it("Finds nodes in settings.nodesDir (string,relative path)",function(done) {
|
||||
var relativeUserDir = path.join("test","unit","@node-red","registry","lib","resources","userDir");
|
||||
console.log(relativeUserDir)
|
||||
localfilesystem.init({settings:{nodesDir:relativeUserDir}});
|
||||
var nodeList = localfilesystem.getNodeFiles(true);
|
||||
nodeList.should.have.a.property("node-red");
|
||||
|
Loading…
Reference in New Issue
Block a user