UNPKG

1.31 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3// Bad news: We have to write plain ES5 in this file
4// Good news: It's the only file of the entire project
5
6/* eslint-disable no-var */
7
8var semver = require('semver');
9var execa = require('execa');
10var findVersions = require('find-versions');
11var pkg = require('../package.json');
12
13var MIN_GIT_VERSION = '2.7.1';
14
15if (!semver.satisfies(process.version, pkg.engines.node)) {
16 console.error(
17 `[semantic-release]: node version ${pkg.engines.node} is required. Found ${process.version}.
18
19See https://github.com/semantic-release/semantic-release/blob/master/docs/support/node-version.md for more details and solutions.`
20 );
21 process.exit(1);
22}
23
24execa('git', ['--version'])
25 .then(({stdout}) => {
26 var gitVersion = findVersions(stdout)[0];
27 if (semver.lt(gitVersion, MIN_GIT_VERSION)) {
28 console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. Found ${gitVersion}.`);
29 process.exit(1);
30 }
31 })
32 .catch((error) => {
33 console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. No git binary found.`);
34 console.error(error);
35 process.exit(1);
36 });
37
38// Node 10+ from this point on
39require('../cli')()
40 .then((exitCode) => {
41 process.exitCode = exitCode;
42 })
43 .catch(() => {
44 process.exitCode = 1;
45 });