mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-26 05:13:05 +07:00
Merge pull request #192 from dsame/fix/json-bom
Add workaround to fix BOM-related error during parsing global.json
This commit is contained in:
commit
53d6483af8
4
dist/index.js
vendored
4
dist/index.js
vendored
@ -7829,7 +7829,9 @@ function run() {
|
||||
core.debug('No version found, trying to find version from global.json');
|
||||
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
||||
if (fs.existsSync(globalJsonPath)) {
|
||||
const globalJson = JSON.parse(fs.readFileSync(globalJsonPath, { encoding: 'utf8' }));
|
||||
const globalJson = JSON.parse(
|
||||
// .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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user