-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
34 lines (27 loc) · 971 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
import { createRequire } from 'node:module';
import log from '@dynamicabot/signales';
import path from 'path';
import url from 'url';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const NODE_ENV = process.env.NODE_ENV || 'production';
let IS_NPM_PACKAGE = false;
try {
const require = createRequire(import.meta.url);
IS_NPM_PACKAGE = !!require.resolve('crittr');
} catch (e) {}
const pathToCrittr = NODE_ENV === 'development' && !IS_NPM_PACKAGE ? 'lib' : 'lib'; // Only keep for later browser support?
/**
*
* @param options
* @returns {Promise<[<string>, <string>]>}
*/
export default async options => {
log.time('Crittr Run');
const { Crittr } = await import(path.join(__dirname, pathToCrittr, 'classes', 'Crittr.class.js'));
let crittr;
let resultObj = { critical: null, rest: null };
crittr = new Crittr(options);
resultObj = await crittr.run();
log.timeEnd('Crittr Run');
return resultObj;
};