-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
40 lines (34 loc) · 1009 Bytes
/
index.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
"use strict";
const log = require("signale");
const path = require("path");
const NODE_ENV = process.env.NODE_ENV || "production";
let IS_NPM_PACKAGE = false;
try {
IS_NPM_PACKAGE = !!require.resolve("crittr");
} catch (e) {}
const pathToCrittr = NODE_ENV === "development" && !IS_NPM_PACKAGE ? "src" : "lib";
const Crittr = require(path.join(__dirname, pathToCrittr, 'classes', 'Crittr.class.js'));
/**
*
* @param options
* @returns {Promise<[<string>, <string>]>}
*/
module.exports = (options) => {
return new Promise(async (resolve, reject) => {
log.time("Crittr Run");
let crittr;
let resultObj = {critical: null, rest: null};
try {
crittr = new Crittr(options);
} catch (err) {
reject(err);
}
try {
(resultObj = await crittr.run());
} catch (err) {
reject(err);
}
resolve(resultObj);
log.timeEnd("Crittr Run");
});
};