Format and Lint code

This commit is contained in:
IvanZosimov 2023-04-03 16:43:33 +02:00
parent 9acb3930fa
commit 55a453935f
2 changed files with 27 additions and 8 deletions

View File

@ -224,9 +224,15 @@ describe('setupJava', () => {
const jdkFile = 'not_existing_one';
const expected = {
version: actualJavaVersion,
path: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture, 'Contents', 'Home')
path: path.join(
'Java_jdkfile_jdk',
inputs.version,
inputs.architecture,
'Contents',
'Home'
)
};
let originalPlatform = process.platform;
const originalPlatform = process.platform;
Object.defineProperty(process, 'platform', {
value: 'darwin'
});
@ -239,7 +245,9 @@ describe('setupJava', () => {
mockJavaBase = new LocalDistribution(inputs, jdkFile);
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyGetToolcachePath).toHaveBeenCalled();
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${actualJavaVersion} from tool-cache`);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Resolved Java ${actualJavaVersion} from tool-cache`
);
expect(spyCoreInfo).not.toHaveBeenCalledWith(
`Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...`
);
@ -259,9 +267,15 @@ describe('setupJava', () => {
const jdkFile = expectedJdkFile;
const expected = {
version: '11.0.289',
path: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture, 'Contents', 'Home')
path: path.join(
'Java_jdkfile_jdk',
inputs.version,
inputs.architecture,
'Contents',
'Home'
)
};
let originalPlatform = process.platform;
const originalPlatform = process.platform;
Object.defineProperty(process, 'platform', {
value: 'darwin'
});
@ -276,7 +290,9 @@ describe('setupJava', () => {
expect(spyCoreInfo).not.toHaveBeenCalledWith(
`Resolved Java ${actualJavaVersion} from tool-cache`
);
expect(spyCoreInfo).toHaveBeenCalledWith(`Extracting Java from '${jdkFile}'`);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Extracting Java from '${jdkFile}'`
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...`
);

View File

@ -47,7 +47,7 @@ export class LocalDistribution extends JavaBase {
const archivePath = path.join(extractedJavaPath, archiveName);
const javaVersion = this.version;
let javaPath = await tc.cacheDir(
const javaPath = await tc.cacheDir(
archivePath,
this.toolcacheFolderName,
this.getToolcacheVersionName(javaVersion),
@ -61,7 +61,10 @@ export class LocalDistribution extends JavaBase {
}
// JDK folder may contain postfix "Contents/Home" on macOS
const macOSPostfixPath = path.join(foundJava.path, MACOS_JAVA_CONTENT_POSTFIX);
const macOSPostfixPath = path.join(
foundJava.path,
MACOS_JAVA_CONTENT_POSTFIX
);
if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) {
foundJava.path = macOSPostfixPath;
}