-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathzxi.mjs
37 lines (27 loc) · 809 Bytes
/
zxi.mjs
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
const { dirname, resolve } = path;
const { pathExists } = fs;
const { cwd, env } = process;
const { _: args } = argv;
const { cyan, green } = chalk;
const CD = args.includes('cd');
const TIME = args.includes('time');
if (CD) args.splice(args.indexOf('cd'), 1);
if (TIME) args.splice(args.indexOf('time'), 1);
const FILE = args.shift();
const DIR = dirname(FILE);
$.verbose = true;
if (await pathExists(`${ DIR }/package.json`)) {
await $({ cwd: DIR })`npm install \
--no-audit \
--no-fund \
--lockfile-version=3 \
--loglevel=error \
--force \
`;
$.preferLocal = [resolve(DIR), cwd()];
}
if (CD) cd(DIR);
env.FORCE_COLOR = '1';
const start = Date.now();
await import(`../${ FILE }`);
if (TIME) echo(green(`\n${ FILE } took ${ cyan((Date.now() - start) / 1000) } seconds`));