Parse global.json with JSON5
This commit is contained in:
parent
3447fd6a9f
commit
d1c99df34e
File diff suppressed because one or more lines are too long
|
@ -17,6 +17,7 @@
|
|||
"@actions/http-client": "^2.0.1",
|
||||
"@actions/io": "^1.0.2",
|
||||
"fast-xml-parser": "^4.0.10",
|
||||
"json5": "^2.2.3",
|
||||
"semver": "^6.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -4902,7 +4903,6 @@
|
|||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
||||
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"json5": "lib/cli.js"
|
||||
},
|
||||
|
@ -10204,8 +10204,7 @@
|
|||
"json5": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
||||
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
|
||||
"dev": true
|
||||
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="
|
||||
},
|
||||
"kleur": {
|
||||
"version": "3.0.3",
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
"@actions/http-client": "^2.0.1",
|
||||
"@actions/io": "^1.0.2",
|
||||
"fast-xml-parser": "^4.0.10",
|
||||
"json5": "^2.2.3",
|
||||
"semver": "^6.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -7,6 +7,7 @@ import * as auth from './authutil';
|
|||
import {isCacheFeatureAvailable} from './cache-utils';
|
||||
import {restoreCache} from './cache-restore';
|
||||
import {Outputs} from './constants';
|
||||
import JSON5 from 'json5';
|
||||
|
||||
const qualityOptions = [
|
||||
'daily',
|
||||
|
@ -97,9 +98,14 @@ export async function run() {
|
|||
|
||||
function getVersionFromGlobalJson(globalJsonPath: string): string {
|
||||
let version = '';
|
||||
const globalJson = JSON.parse(
|
||||
const globalJson = JSON5.parse(
|
||||
// .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649
|
||||
fs.readFileSync(globalJsonPath, {encoding: 'utf8'}).trim()
|
||||
fs.readFileSync(globalJsonPath, {encoding: 'utf8'}).trim(),
|
||||
// is necessary as JSON5 supports wider variety of options for numbers: https://www.npmjs.com/package/json5#numbers
|
||||
(key, value) => {
|
||||
if (key === 'version' || key === 'rollForward') return String(value);
|
||||
return value;
|
||||
}
|
||||
);
|
||||
if (globalJson.sdk && globalJson.sdk.version) {
|
||||
version = globalJson.sdk.version;
|
||||
|
|
Loading…
Reference in New Issue