fix(install): accept UTF-8 BOM in install configs

This commit is contained in:
Yann Roberto
2026-09-22 21:04:57 +08:00
parent bf70150eb2
commit 94ca2de35e
3 changed files with 83 additions and 1 deletions
+3 -1
View File
@@ -10,7 +10,9 @@ let cachedValidator = null;
function readJson(filePath, label) {
try {
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
// Windows PowerShell 5.1 writes a BOM with Set-Content -Encoding UTF8.
const content = fs.readFileSync(filePath, 'utf8').replace(/^\uFEFF/, '');
return JSON.parse(content);
} catch (error) {
throw new Error(`Invalid JSON in ${label}: ${error.message}`);
}