forked from ad-si/symlink-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·40 lines (35 loc) · 1.03 KB
/
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
35
36
37
38
39
40
#! /usr/bin/env node
'use strict'
const process = require('process');
const minimist = require('minimist');
const linkpkg = require('./index.js');
const usage = [
'linkpkg [(-d|--dir) FOLDER] [(-r|--root) ROOT] [PKG ...]',
'',
'Arguments:',
' PKG list of packages to link separated with space',
' -d, --dir path to linked packages folder (default: linked_modules)',
` -r, --root path used as staring point for package resolution (default: ${process.cwd()})`,
].join('\n');
const args = minimist(process.argv.slice(2), {
boolean: ['help'],
string: ['dir', 'root'],
alias: {
'dir': 'd',
'root': 'r',
'help': 'h'
},
default: {
'dir': 'linked_modules',
'root': process.cwd()
}
})
if (args.help) {
return console.log(usage);
}
linkpkg(args._, args.root, args.dir).forEach(printpkg);
function printpkg(pkg) {
if (pkg && pkg.name && pkg.path && pkg.link) {
console.log(`linked ${pkg.name}: ${pkg.path} -> ${pkg.link}`);
}
}