mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-01 13:33:15 +00:00
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:
parent
731512c2e5
commit
d9eefff066
@ -36,6 +36,7 @@ _This release is scheduled to be released on 2024-10-01._
|
|||||||
- [core] Detail optimizations in `config_check.js`
|
- [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)
|
- [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`
|
- [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
|
### Fixed
|
||||||
|
|
||||||
|
33
js/utils.js
33
js/utils.js
@ -49,21 +49,24 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getModulePositions () {
|
getModulePositions () {
|
||||||
// get the lines of the index.html
|
// if not already discovered
|
||||||
const lines = fs.readFileSync(indexFileName).toString().split(os.EOL);
|
if (modulePositions.length === 0) {
|
||||||
// loop thru the lines
|
// get the lines of the index.html
|
||||||
lines.forEach((line) => {
|
const lines = fs.readFileSync(indexFileName).toString().split(os.EOL);
|
||||||
// run the regex on each line
|
// loop thru the lines
|
||||||
const results = regionRegEx.exec(line);
|
lines.forEach((line) => {
|
||||||
// if the regex returned something
|
// run the regex on each line
|
||||||
if (results && results.length > 0) {
|
const results = regionRegEx.exec(line);
|
||||||
// get the position parts and replace space with underscore
|
// if the regex returned something
|
||||||
const positionName = results[1].replace(" ", "_");
|
if (results && results.length > 0) {
|
||||||
// add it to the list
|
// get the position parts and replace space with underscore
|
||||||
modulePositions.push(positionName);
|
const positionName = results[1].replace(" ", "_");
|
||||||
}
|
// add it to the list
|
||||||
});
|
modulePositions.push(positionName);
|
||||||
fs.writeFileSync(discoveredPositionsJSFilename, `const modulePositions=${JSON.stringify(modulePositions)}`);
|
}
|
||||||
|
});
|
||||||
|
fs.writeFileSync(discoveredPositionsJSFilename, `const modulePositions=${JSON.stringify(modulePositions)}`);
|
||||||
|
}
|
||||||
// return the list to the caller
|
// return the list to the caller
|
||||||
return modulePositions;
|
return modulePositions;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user