remove unused import

This commit is contained in:
Evgenii Korolevskii 2022-11-24 19:24:01 +01:00
parent 53d9cbe60a
commit e2c02857f1
2 changed files with 30 additions and 22 deletions

15
dist/setup/index.js vendored
View File

@ -105184,13 +105184,16 @@ function run() {
toolchainIds = []; toolchainIds = [];
} }
if (!versions.length) { if (!versions.length) {
core.debug("JAVA_VERSION input is empty, looking for .java-version file"); core.debug('JAVA_VERSION input is empty, looking for .java-version file');
const versionFileName = '.java-version'; const versionFileName = '.java-version';
const contents = fs_1.default.readFileSync(versionFileName).toString().trim(); const contents = fs_1.default
.readFileSync(versionFileName)
.toString()
.trim();
const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/; const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/;
let version = semverRegExp.test(contents) ? RegExp.$1 : ""; let version = semverRegExp.test(contents) ? RegExp.$1 : '';
let installed = false; let installed = false;
while (!installed && version != "") { while (!installed && version != '') {
try { try {
core.debug(`Trying to install version ${version}`); core.debug(`Trying to install version ${version}`);
yield installVersion(version); yield installVersion(version);
@ -105238,7 +105241,9 @@ function run() {
}); });
} }
function getHigherVersion(version) { function getHigherVersion(version) {
return version.split("-")[0] === version ? version.substring(0, version.lastIndexOf(".")) : version.split("-")[0]; return version.split('-')[0] === version
? version.substring(0, version.lastIndexOf('.'))
: version.split('-')[0];
} }
} }
catch (error) { catch (error) {

View File

@ -1,4 +1,4 @@
import fs from "fs"; import fs from 'fs';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as auth from './auth'; import * as auth from './auth';
import { getBooleanInput, isCacheFeatureAvailable } from './util'; import { getBooleanInput, isCacheFeatureAvailable } from './util';
@ -8,7 +8,6 @@ import { restore } from './cache';
import * as path from 'path'; import * as path from 'path';
import { getJavaDistribution } from './distributions/distribution-factory'; import { getJavaDistribution } from './distributions/distribution-factory';
import { JavaInstallerOptions } from './distributions/base-models'; import { JavaInstallerOptions } from './distributions/base-models';
import * as semver from 'semver';
async function run() { async function run() {
try { try {
@ -28,29 +27,32 @@ async function run() {
} }
if (!versions.length) { if (!versions.length) {
core.debug("JAVA_VERSION input is empty, looking for .java-version file") core.debug('JAVA_VERSION input is empty, looking for .java-version file');
const versionFileName = '.java-version' const versionFileName = '.java-version';
const contents = fs.readFileSync(versionFileName).toString().trim(); const contents = fs
const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/ .readFileSync(versionFileName)
let version = semverRegExp.test(contents) ? RegExp.$1 : ""; .toString()
.trim();
const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/;
let version = semverRegExp.test(contents) ? RegExp.$1 : '';
let installed = false; let installed = false;
while (!installed && version != "") { while (!installed && version != '') {
try { try {
core.debug(`Trying to install version ${version}`) core.debug(`Trying to install version ${version}`);
await installVersion(version) await installVersion(version);
installed = true installed = true;
} catch (error) { } catch (error) {
core.debug(`${error.toString()}`); core.debug(`${error.toString()}`);
version = getHigherVersion(version) version = getHigherVersion(version);
} }
} }
if (!installed) { if (!installed) {
throw new Error("Сan't install appropriate version from .java-version file") throw new Error("Сan't install appropriate version from .java-version file");
} }
} }
for (const [index, version] of versions.entries()) { for (const [index, version] of versions.entries()) {
await installVersion(version, index) await installVersion(version, index);
} }
core.endGroup(); core.endGroup();
const matchersPath = path.join(__dirname, '..', '..', '.github'); const matchersPath = path.join(__dirname, '..', '..', '.github');
@ -91,9 +93,10 @@ async function run() {
} }
function getHigherVersion(version: string) { function getHigherVersion(version: string) {
return version.split("-")[0] === version ? version.substring(0, version.lastIndexOf(".")) : version.split("-")[0] return version.split('-')[0] === version
? version.substring(0, version.lastIndexOf('.'))
: version.split('-')[0];
} }
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }