From 2c3efd1f04468c94b6b2459474b474f8c4893cc4 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Fri, 20 Aug 2021 17:28:10 +0300 Subject: [PATCH] Improve condition --- dist/index.js | 7 ++++--- src/setup-dotnet.ts | 8 +++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5dff700..a9c4d74 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7853,15 +7853,16 @@ function run() { } exports.run = run; function getVersionFromGlobalJson(globalJsonPath) { + var _a; + const optionValues = ['latestFeature', 'latestPatch']; let version = ''; 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; - const rollForward = globalJson.sdk.rollForward; - if (rollForward && - (rollForward === 'latestFeature' || rollForward === 'latestPatch')) { + const rollForward = (_a = globalJson.sdk.rollForward) !== null && _a !== void 0 ? _a : ''; + if (optionValues.includes(rollForward)) { const [major, minor] = version.split('.'); version = `${major}.${minor}`; } diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index c704802..eea9916 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -49,6 +49,7 @@ export async function run() { } function getVersionFromGlobalJson(globalJsonPath: string): string { + const optionValues = ['latestFeature', 'latestPatch'] let version: string = ''; const globalJson = JSON.parse( // .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649 @@ -56,11 +57,8 @@ function getVersionFromGlobalJson(globalJsonPath: string): string { ); if (globalJson.sdk && globalJson.sdk.version) { version = globalJson.sdk.version; - const rollForward = globalJson.sdk.rollForward; - if ( - rollForward && - (rollForward === 'latestFeature' || rollForward === 'latestPatch') - ) { + const rollForward = globalJson.sdk.rollForward ?? ''; + if (optionValues.includes(rollForward)) { const [major, minor] = version.split('.'); version = `${major}.${minor}`; }