Allow .cjs, .mjs as well as .js

This commit is contained in:
Pez Cuckow 2024-01-08 15:06:48 +01:00
parent 0589e1f470
commit 4920611b69
No known key found for this signature in database

View File

@ -72,11 +72,11 @@ function getLocalFile(file) {
return null;
}
try {
fs.statSync(file.replace(/\.js$/,".html"));
fs.statSync(file.replace(/\.[\w]?js$/, '.html'));
return {
file: file,
module: "node-red",
name: path.basename(file).replace(/^\d+-/,"").replace(/\.js$/,""),
name: path.basename(file).replace(/^\d+-/,"").replace(/\.[\w]?js$/,""),
version: settings.version
};
} catch(err) {
@ -114,7 +114,7 @@ function getLocalNodeFiles(dir, skipValidNodeRedModules) {
files.forEach(function(fn) {
var stats = fs.statSync(path.join(dir,fn));
if (stats.isFile()) {
if (/\.js$/.test(fn)) {
if (/\.[\w]?js$/.test(fn)) {
var info = getLocalFile(path.join(dir,fn));
if (info) {
result.push(info);