mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 02:16:45 +00:00
Implement support for custom vendors in setup-java
This commit is contained in:
parent
e73e96a93b
commit
b2da088220
21 changed files with 34331 additions and 21391 deletions
55
src/util.ts
55
src/util.ts
|
@ -1,26 +1,41 @@
|
|||
import * as path from 'path';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
import * as tc from '@actions/tool-cache';
|
||||
|
||||
export function getTempDir() {
|
||||
let tempDirectory = process.env.RUNNER_TEMP;
|
||||
if (tempDirectory === undefined) {
|
||||
let baseLocation;
|
||||
if (isWindows()) {
|
||||
// On windows use the USERPROFILE env variable
|
||||
baseLocation = process.env['USERPROFILE']
|
||||
? process.env['USERPROFILE']
|
||||
: 'C:\\';
|
||||
} else {
|
||||
if (process.platform === 'darwin') {
|
||||
baseLocation = '/Users';
|
||||
} else {
|
||||
baseLocation = '/home';
|
||||
}
|
||||
}
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||
}
|
||||
let tempDirectory = process.env['RUNNER_TEMP'] || os.tmpdir();
|
||||
|
||||
return tempDirectory;
|
||||
}
|
||||
|
||||
export function isWindows() {
|
||||
return process.platform === 'win32';
|
||||
export function getVersionFromToolcachePath(toolPath: string) {
|
||||
if (toolPath) {
|
||||
return path.basename(path.dirname(toolPath));
|
||||
}
|
||||
|
||||
return toolPath;
|
||||
}
|
||||
|
||||
export async function extractJdkFile(toolPath: string, extension?: string) {
|
||||
if (!extension) {
|
||||
extension = toolPath.endsWith('.tar.gz') ? 'tar.gz' : path.extname(toolPath);
|
||||
if (extension.startsWith('.')) {
|
||||
extension = extension.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
switch (extension) {
|
||||
case 'tar.gz':
|
||||
case 'tar':
|
||||
return await tc.extractTar(toolPath);
|
||||
case 'zip':
|
||||
return await tc.extractZip(toolPath);
|
||||
default:
|
||||
return await tc.extract7z(toolPath);
|
||||
}
|
||||
}
|
||||
|
||||
export function getDownloadArchiveExtension() {
|
||||
return process.platform === 'win32' ? 'zip' : 'tar.gz';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue