Skip to content

Commit 2c3efd1

Browse files
author
Vladimir Safonkin
committed
Improve condition
1 parent f3822c3 commit 2c3efd1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

dist/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7853,15 +7853,16 @@ function run() {
78537853
}
78547854
exports.run = run;
78557855
function getVersionFromGlobalJson(globalJsonPath) {
7856+
var _a;
7857+
const optionValues = ['latestFeature', 'latestPatch'];
78567858
let version = '';
78577859
const globalJson = JSON.parse(
78587860
// .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649
78597861
fs.readFileSync(globalJsonPath, { encoding: 'utf8' }).trim());
78607862
if (globalJson.sdk && globalJson.sdk.version) {
78617863
version = globalJson.sdk.version;
7862-
const rollForward = globalJson.sdk.rollForward;
7863-
if (rollForward &&
7864-
(rollForward === 'latestFeature' || rollForward === 'latestPatch')) {
7864+
const rollForward = (_a = globalJson.sdk.rollForward) !== null && _a !== void 0 ? _a : '';
7865+
if (optionValues.includes(rollForward)) {
78657866
const [major, minor] = version.split('.');
78667867
version = `${major}.${minor}`;
78677868
}

src/setup-dotnet.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,16 @@ export async function run() {
4949
}
5050

5151
function getVersionFromGlobalJson(globalJsonPath: string): string {
52+
const optionValues = ['latestFeature', 'latestPatch']
5253
let version: string = '';
5354
const globalJson = JSON.parse(
5455
// .trim() is necessary to strip BOM https://github.com/nodejs/node/issues/20649
5556
fs.readFileSync(globalJsonPath, {encoding: 'utf8'}).trim()
5657
);
5758
if (globalJson.sdk && globalJson.sdk.version) {
5859
version = globalJson.sdk.version;
59-
const rollForward = globalJson.sdk.rollForward;
60-
if (
61-
rollForward &&
62-
(rollForward === 'latestFeature' || rollForward === 'latestPatch')
63-
) {
60+
const rollForward = globalJson.sdk.rollForward ?? '';
61+
if (optionValues.includes(rollForward)) {
6462
const [major, minor] = version.split('.');
6563
version = `${major}.${minor}`;
6664
}

0 commit comments

Comments
 (0)