From f987fa13ea5581d5c6c6320836829632190dd800 Mon Sep 17 00:00:00 2001 From: Andrey Bezugliy Date: Mon, 10 Apr 2017 17:41:20 +0300 Subject: [PATCH] Resolve dir argument of getLocalNodeFiles function (#1216) * Resolve dir argument of getLocalNodeFiles function The getLocalNodeFiles is called 3 times. Each time it called, the callee needs to resolve the dir argument. That was not done for several of calls, and local modules (specified in the "nodesDir" setting) were not returned to client because of that. This fix will allow to make sure the dir is consistently resolved. * Several changes in "localfilesystem_spec.js": - Changed checkNodes to verify that every node's file property is resolved, i.e. containst absolute path, not relative. - Added a unit-test "Finds nodes in settings.nodesDir (string,relative path)" --- red/runtime/nodes/registry/localfilesystem.js | 4 +++- .../runtime/nodes/registry/localfilesystem_spec.js | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/red/runtime/nodes/registry/localfilesystem.js b/red/runtime/nodes/registry/localfilesystem.js index 8e76fc79e..acb054749 100644 --- a/red/runtime/nodes/registry/localfilesystem.js +++ b/red/runtime/nodes/registry/localfilesystem.js @@ -67,6 +67,8 @@ function getLocalFile(file) { * @return an array of fully-qualified paths to .js files */ function getLocalNodeFiles(dir) { + dir = path.resolve(dir); + var result = []; var files = []; try { @@ -205,7 +207,7 @@ function getNodeFiles(disableNodePathScan) { if (settings.coreNodesDir) { nodeFiles = getLocalNodeFiles(path.resolve(settings.coreNodesDir)); - var defaultLocalesPath = path.resolve(path.join(settings.coreNodesDir,"core","locales")); + var defaultLocalesPath = path.join(settings.coreNodesDir,"core","locales"); i18n.registerMessageCatalog("node-red",defaultLocalesPath,"messages.json"); } diff --git a/test/red/runtime/nodes/registry/localfilesystem_spec.js b/test/red/runtime/nodes/registry/localfilesystem_spec.js index 6bfdbde9a..bffdf291e 100644 --- a/test/red/runtime/nodes/registry/localfilesystem_spec.js +++ b/test/red/runtime/nodes/registry/localfilesystem_spec.js @@ -36,6 +36,7 @@ describe("red/nodes/registry/localfilesystem",function() { for (var i=0;i