mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Update all node icons to SVG
When listing icons provided by a module, if there is a png and svg with the same name, only the svg will be listed. If a node asks for a png icon which is not known, but there is a corresponding svg, that will be used instead.
This commit is contained in:
@@ -372,18 +372,27 @@ function getModuleFiles(module) {
|
||||
return nodeList;
|
||||
}
|
||||
|
||||
// If this finds an svg and a png with the same name, it will only list the svg
|
||||
function scanIconDir(dir) {
|
||||
var iconList = [];
|
||||
var svgs = {};
|
||||
try {
|
||||
var files = fs.readdirSync(dir);
|
||||
files.forEach(function(file) {
|
||||
var stats = fs.statSync(path.join(dir, file));
|
||||
if (stats.isFile() && iconFileExtensions.indexOf(path.extname(file)) !== -1) {
|
||||
var ext = path.extname(file).toLowerCase();
|
||||
if (stats.isFile() && iconFileExtensions.indexOf(ext) !== -1) {
|
||||
iconList.push(file);
|
||||
if (ext === ".svg") {
|
||||
svgs[file.substring(0,file.length-4)] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch(err) {
|
||||
}
|
||||
iconList = iconList.filter(f => {
|
||||
return /.svg$/i.test(f) || !svgs[f.substring(0,f.length-4)]
|
||||
})
|
||||
return iconList;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user