blob: 8eb7e592dadb31bbe36aba879b4c942174cb2c24 (
plain)
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
|
import semver from 'semver';
import { simpleGit } from 'simple-git';
const GIT_MINIMUM_VERSION = '2.33.0';
const git = simpleGit();
await (async () => {
try {
const { major, minor, patch, installed } = await git.version();
const gitVersion = `${major}.${minor}.${patch}`;
if (!installed || semver.lt(gitVersion, GIT_MINIMUM_VERSION)) {
if (process.env.CI) {
console.log(
`::error ::Minimum Git version ${GIT_MINIMUM_VERSION} is required, found version '${gitVersion}'.`,
);
} else {
throw new Error(
`Minimum Git version ${GIT_MINIMUM_VERSION} is required, found version '${gitVersion}'.`,
);
}
}
console.log('Found git version: ', gitVersion);
process.exit(0);
} catch (err) {
console.log('ERROR:', err.message);
process.exit(1);
}
})();
|