fix double load of positions now that check:config at startup is active (#3565)

after adding check:config to the MM startup process, #3450, we
accidentally discover module positions more than once, and write the
file each time..

add a check to see if we have done this work already
This commit is contained in:
sam detweiler 2024-09-28 08:52:09 -05:00 committed by GitHub
parent 731512c2e5
commit d9eefff066
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 15 deletions

View File

@ -36,6 +36,7 @@ _This release is scheduled to be released on 2024-10-01._
- [core] Detail optimizations in `config_check.js`
- [core] Updated minimal needed node version in `package.json` (currently v20.9.0) (#3559) and except for v21 (no security updates) (#3561)
- [linter] Switch to ESLint v9 and flat config and replace `eslint-plugin-unicorn` by `@eslint/js`
- [core] fix discovering module positions twice after #3450
### Fixed

View File

@ -49,6 +49,8 @@ module.exports = {
},
getModulePositions () {
// if not already discovered
if (modulePositions.length === 0) {
// get the lines of the index.html
const lines = fs.readFileSync(indexFileName).toString().split(os.EOL);
// loop thru the lines
@ -64,6 +66,7 @@ module.exports = {
}
});
fs.writeFileSync(discoveredPositionsJSFilename, `const modulePositions=${JSON.stringify(modulePositions)}`);
}
// return the list to the caller
return modulePositions;
}