/
utils.ts
42 lines (34 loc) · 1.01 KB
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { join } from 'upath';
import { getGlobalConfig } from '../../../config/global';
import { localPathExists, readLocalFile } from '../../../util/fs';
import {
extractGradleVersion,
getJavaContraint,
} from '../../gradle-wrapper/utils';
const GradleWrapperProperties = 'gradle/wrapper/gradle-wrapper.properties';
export async function getDockerConstraint(
gradleRoot: string
): Promise<string | null> {
if (getGlobalConfig()?.binarySource !== 'docker') {
// ignore
return null;
}
const fileContent = await readLocalFile(
join(gradleRoot, GradleWrapperProperties),
'utf8'
);
const version = extractGradleVersion(fileContent)?.version;
return getJavaContraint(version);
}
export async function getDockerPreCommands(
gradleRoot: string
): Promise<string[]> {
if (getGlobalConfig()?.binarySource !== 'docker') {
// ignore
return null;
}
if (await localPathExists(join(gradleRoot, GradleWrapperProperties))) {
return null;
}
return ['install-tool gradle latest'];
}