Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion dist/index.js
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/setup-dotnet.ts
Expand Up @@ -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;
Expand Down