Add workaround to fix BOM-related error during parsing global.json

This commit is contained in:
Sergey Dolin 2021-04-28 13:43:02 +05:00
parent 23fa2c1473
commit bd485b6bd1

View File

@ -20,7 +20,8 @@ export async function run() {
const globalJsonPath = path.join(process.cwd(), 'global.json');
if (fs.existsSync(globalJsonPath)) {
const globalJson = JSON.parse(
fs.readFileSync(globalJsonPath, {encoding: 'utf8'})
// .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649
fs.readFileSync(globalJsonPath, {encoding: 'utf8'}).trim()
);
if (globalJson.sdk && globalJson.sdk.version) {
version = globalJson.sdk.version;