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

Enable it to store icon files in {settings.userDir}/lib/icons directory for dynamic nodes's icon feature (#1536)

This commit is contained in:
Kazuki Nakanishi 2018-01-05 23:23:47 +09:00 committed by Nick O'Leary
parent ff8773f6bd
commit 63f7d826bc
4 changed files with 34 additions and 4 deletions

View File

@ -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));
}

View File

@ -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) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B