-
Notifications
You must be signed in to change notification settings - Fork 0
/
bin.js
executable file
·35 lines (31 loc) · 1.04 KB
/
bin.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
#!/usr/bin/env node
const { program } = require('commander');
const chalk = require('chalk');
const listDeps = require('.');
program
.name('list-deps')
.description('List imported JavaScript dependencies')
.version('0.1.5')
.argument(
'<root-file-path>',
'Root file from which to search for dependencies',
)
.option(
'-e --extensions <extensions...>',
'File extensions to look for when resolving modules',
['js'],
)
.action((rootFilePath, { extensions }) => {
const { skippedModules, dependencies } = listDeps(rootFilePath, extensions);
if (skippedModules.length > 0) {
console.warn(chalk.bgYellow(` ${skippedModules.length} Modules skipped `));
for (const modulePath of skippedModules) {
console.warn(modulePath);
}
}
console.log(chalk.bgGreen(` ${dependencies.length} Dependencies found `))
for (const dependency of dependencies) {
console.log(dependency);
}
})
.parse()