-
Notifications
You must be signed in to change notification settings - Fork 109
/
gemini-ci.js
42 lines (32 loc) · 1.16 KB
/
gemini-ci.js
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
/* eslint @typescript-eslint/no-var-requires: 0 */
/* eslint import/no-extraneous-dependencies: [2, {"devDependencies": true}] */
/* eslint no-confusing-arrow: 0 */
/* eslint strict: [0, "global"] */
'use strict';
const Gemini = require('gemini/api');
const Events = require('gemini/lib/constants/events');
const handleErrors = require('gemini/lib/cli/errors').handleErrors;
const checkForDeprecations = require('gemini/lib/cli/deprecations').checkForDeprecations;
const handleUncaughtExceptions = require('gemini/lib/cli/errors').handleUncaughtExceptions;
function exit(code) {
process.exit(code);
}
function promiseTry(func) {
return new Promise((resolve) => resolve(func()));
}
function runGemini(paths = []) {
handleUncaughtExceptions();
return promiseTry(() => {
checkForDeprecations();
const gemini = new Gemini();
gemini.on(Events.INTERRUPT, (data) => {
exit(data.exitCode);
});
return gemini;
})
.then((gemini) => gemini.test(paths, { reporters: [{ name: 'flat' }] }))
.then((stats) => stats.failed > 0 ? 2 : 0)
.catch(handleErrors)
.then(exit);
}
runGemini();