Skip to content

Commit

Permalink
regenerate dist
Browse files Browse the repository at this point in the history
  • Loading branch information
omsmith committed Apr 11, 2022
1 parent b9b4b0b commit 2dbc816
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions dist/index.js
Expand Up @@ -9115,18 +9115,16 @@ function run() {
//
// dotnet-version is optional, but needs to be provided for most use cases.
// If supplied, install / use from the tool cache.
// If not supplied, look for version in ./global.json.
// global-version-file may be specified to point to a specific global.json
// and will be used to install an additional version.
// If neither supplied, look for version in ./global.json.
// If a valid version still can't be identified, nothing will be installed.
// Proxy, auth, (etc) are still set up, even if no version is identified
//
let versions = core.getMultilineInput('dotnet-version');
if (!versions.length) {
// Try to fall back to global.json
core.debug('No version found, trying to find version from global.json');
const globalJsonPath = path.join(process.cwd(), 'global.json');
if (fs.existsSync(globalJsonPath)) {
versions.push(getVersionFromGlobalJson(globalJsonPath));
}
const globalJsonVersion = getVersionFromGlobalJson(versions.length > 0);
if (globalJsonVersion) {
versions.push(globalJsonVersion);
}
if (versions.length) {
const includePrerelease = (core.getInput('include-prerelease') || 'false').toLowerCase() ===
Expand All @@ -9152,20 +9150,39 @@ function run() {
});
}
exports.run = run;
function getVersionFromGlobalJson(globalJsonPath) {
let version = '';
function getVersionFromGlobalJson(hasVersions) {
const globalJsonFileInput = core.getInput('global-json-file');
if (!globalJsonFileInput) {
if (hasVersions) {
// Don't check for a global.json if dotnet-version was specified and
// global-json-file was not
return null;
}
// Falling back to global.json
core.debug('No version found, trying to find version from global.json');
}
const globalJsonPath = globalJsonFileInput
? path.join(process.cwd(), globalJsonFileInput)
: path.join(process.cwd(), 'global.json');
if (!fs.existsSync(globalJsonPath)) {
if (globalJsonFileInput) {
throw new Error(`The specified global.json file at: ${globalJsonFileInput} does not exist`);
}
return null;
}
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;
let version = globalJson.sdk.version;
const rollForward = globalJson.sdk.rollForward;
if (rollForward && rollForward === 'latestFeature') {
const [major, minor] = version.split('.');
version = `${major}.${minor}`;
}
return version;
}
return version;
return null;
}
run();

Expand Down

0 comments on commit 2dbc816

Please sign in to comment.