-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcli.js
34 lines (25 loc) · 879 Bytes
/
cli.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
#!/usr/bin/env node
'use strict';
const mod = require('module');
const proc = require('process');
const allModulesPaths = require('all-module-paths');
const cli = require('./index');
// eslint-disable-next-line no-underscore-dangle
const paths = mod._nodeModulePaths(proc.cwd());
const dirs = allModulesPaths({ paths });
const PATH = dirs.allPaths.binaries.join(':');
proc.env.PATH = `${PATH}:${process.env.PATH}`;
/* eslint-disable promise/always-return */
cli(null, { env: proc.env })
.then((res) => {
// if not an array, then there's no task given, so show all
if (!Array.isArray(res)) {
console.log('Available scripts, choose one:');
Object.keys(res)
.filter((x) => !['start', 'extends', 'presets'].includes(x))
.forEach((taskName) => {
console.log('-', taskName);
});
}
})
.catch(() => proc.exit(1));