forked from philipp-winterle/crittr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (35 loc) · 1.04 KB
/
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
41
42
'use strict';
global.crittr_project_path = __dirname;
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 ? 'lib' : 'lib'; // Only keep for later browser support?
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');
});
};