diff --git a/red/runtime/nodes/registry/localfilesystem.js b/red/runtime/nodes/registry/localfilesystem.js index 4a4581e90..26562c50d 100644 --- a/red/runtime/nodes/registry/localfilesystem.js +++ b/red/runtime/nodes/registry/localfilesystem.js @@ -232,6 +232,12 @@ function getNodeFiles(disableNodePathScan) { } if (settings.userDir) { + dir = path.join(settings.userDir,"lib","icons"); + iconList = scanIconDir(dir); + if (iconList.length > 0) { + events.emit("node-icon-dir",{name:'Library',path:dir,icons:iconList}); + } + dir = path.join(settings.userDir,"nodes"); nodeFiles = nodeFiles.concat(getLocalNodeFiles(dir)); } diff --git a/test/red/runtime/nodes/registry/localfilesystem_spec.js b/test/red/runtime/nodes/registry/localfilesystem_spec.js index 2bdc741f8..d240e2ca5 100644 --- a/test/red/runtime/nodes/registry/localfilesystem_spec.js +++ b/test/red/runtime/nodes/registry/localfilesystem_spec.js @@ -155,10 +155,12 @@ describe("red/nodes/registry/localfilesystem",function() { localfilesystem.init({ i18n:{registerMessageCatalog:function(){}}, events:{emit:function(eventName,dir){ - eventName.should.equal("node-icon-dir"); - dir.name.should.equal("node-red"); - dir.icons.should.be.an.Array(); - if (count++ === 1) { + if (count === 0) { + eventName.should.equal("node-icon-dir"); + dir.name.should.equal("node-red"); + dir.icons.should.be.an.Array(); + count = 1; + } else if (count === 1) { done(); } }}, @@ -166,6 +168,28 @@ describe("red/nodes/registry/localfilesystem",function() { }); localfilesystem.getNodeFiles(true); }); + it("scans icons dir in library",function(done) { + var count = 0; + localfilesystem.init({ + i18n:{registerMessageCatalog:function(){}}, + events:{emit:function(eventName,dir){ + eventName.should.equal("node-icon-dir"); + if (count === 0) { + dir.name.should.equal("node-red"); + dir.icons.should.be.an.Array(); + count = 1; + } else if (count === 1) { + dir.name.should.equal("Library"); + dir.icons.should.be.an.Array(); + dir.icons.length.should.equal(1); + dir.icons[0].should.be.equal("test_icon.png"); + done(); + } + }}, + settings:{userDir:userDir} + }); + localfilesystem.getNodeFiles(true); + }); }); describe("#getModuleFiles",function() { it("gets a nodes module files",function(done) { diff --git a/test/red/runtime/nodes/resources/userDir/lib/icons/file.txt b/test/red/runtime/nodes/resources/userDir/lib/icons/file.txt new file mode 100644 index 000000000..e69de29bb diff --git a/test/red/runtime/nodes/resources/userDir/lib/icons/test_icon.png b/test/red/runtime/nodes/resources/userDir/lib/icons/test_icon.png new file mode 100644 index 000000000..4b6b7b5e9 Binary files /dev/null and b/test/red/runtime/nodes/resources/userDir/lib/icons/test_icon.png differ