mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-10-26 06:19:53 +00:00
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:
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user