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:
parent
ff8773f6bd
commit
63f7d826bc
@ -232,6 +232,12 @@ function getNodeFiles(disableNodePathScan) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (settings.userDir) {
|
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");
|
dir = path.join(settings.userDir,"nodes");
|
||||||
nodeFiles = nodeFiles.concat(getLocalNodeFiles(dir));
|
nodeFiles = nodeFiles.concat(getLocalNodeFiles(dir));
|
||||||
}
|
}
|
||||||
|
@ -155,10 +155,12 @@ describe("red/nodes/registry/localfilesystem",function() {
|
|||||||
localfilesystem.init({
|
localfilesystem.init({
|
||||||
i18n:{registerMessageCatalog:function(){}},
|
i18n:{registerMessageCatalog:function(){}},
|
||||||
events:{emit:function(eventName,dir){
|
events:{emit:function(eventName,dir){
|
||||||
eventName.should.equal("node-icon-dir");
|
if (count === 0) {
|
||||||
dir.name.should.equal("node-red");
|
eventName.should.equal("node-icon-dir");
|
||||||
dir.icons.should.be.an.Array();
|
dir.name.should.equal("node-red");
|
||||||
if (count++ === 1) {
|
dir.icons.should.be.an.Array();
|
||||||
|
count = 1;
|
||||||
|
} else if (count === 1) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
@ -166,6 +168,28 @@ describe("red/nodes/registry/localfilesystem",function() {
|
|||||||
});
|
});
|
||||||
localfilesystem.getNodeFiles(true);
|
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() {
|
describe("#getModuleFiles",function() {
|
||||||
it("gets a nodes module files",function(done) {
|
it("gets a nodes module files",function(done) {
|
||||||
|
BIN
test/red/runtime/nodes/resources/userDir/lib/icons/test_icon.png
Normal file
BIN
test/red/runtime/nodes/resources/userDir/lib/icons/test_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 163 B |
Loading…
x
Reference in New Issue
Block a user