Skip to content

Commit

Permalink
Improve condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Safonkin committed Aug 20, 2021
1 parent f3822c3 commit 2c3efd1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 4 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
Expand Down
8 changes: 3 additions & 5 deletions src/setup-dotnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,16 @@ 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
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 = globalJson.sdk.rollForward ?? '';
if (optionValues.includes(rollForward)) {
const [major, minor] = version.split('.');
version = `${major}.${minor}`;
}
Expand Down

0 comments on commit 2c3efd1

Please sign in to comment.