fix(update): preserve explicit config file extensions

Prevent the console repair scan from turning JSON requires into .json.js download paths.

Thanks: INSOLVE (Honorary); Marco Jakobs (@jacotec); MyNameisStitch (@MyNameisStitch); Redspin (@playerumpknow)
This commit is contained in:
UNITRONIX
2026-09-19 11:04:38 +02:00
parent a93c06d483
commit 36da8a112d
2 changed files with 9 additions and 0 deletions
+7
View File
@@ -36,6 +36,13 @@ function createConsoleDeployGraph(rootDir) {
return path.posix.join(resolved, 'index.js');
}
// Preserve explicit non-JavaScript extensions such as .json.
// Appending .js here turns require('./config/theme.json') into
// the invalid repair path config/theme.json.js.
if (/\.(?:json|ya?ml|css|html?|txt|svg|xml|toml|ini)$/i.test(resolved)) {
return resolved;
}
if (!resolved.endsWith('.js')) resolved += '.js';
const absJs = path.join(rootDir, resolved);
if (!fs.existsSync(absJs)) {
@@ -27,6 +27,8 @@ describe('updateService console sync helpers', () => {
const graph = createConsoleDeployGraph(require('path').join(__dirname, '..'));
expect(graph.resolveConsoleRequire('routes/auth.routes.js', '../services/serverAttestation'))
.toBe('services/serverAttestation.js');
expect(graph.resolveConsoleRequire('services/brandingService.js', '../config/theme-palettes.json'))
.toBe('config/theme-palettes.json');
expect(graph.resolveConsoleRequire('routes/index.js', './devices.routes'))
.toBe('routes/devices.routes.js');
expect(graph.resolveConsoleRequire('server.js', './routes'))