/
unlink.js
executable file
路51 lines (46 loc) 路 1.42 KB
/
unlink.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
41
42
43
44
45
46
47
48
49
50
51
#! /usr/bin/env node
// @flow strict-local
/* eslint-disable no-console */
// $FlowFixMe[untyped-import]
require('@parcel/babel-register');
/*::
import typeof Commander from 'commander';
*/
// $FlowFixMe[incompatible-type]
// $FlowFixMe[prop-missing]
const commander /*: Commander */ = require('commander');
// $FlowFixMe[untyped-import]
const {version} = require('../package.json');
const unlink = require('../src/unlink').default;
const program = new commander.Command();
program
.arguments('[packageRoot]')
.version(version, '-V, --version')
.description('Unlink a dev copy of Parcel from an app')
.option('-d, --dry-run', 'Do not write any changes')
.option('-f, --force-install', 'Force a reinstall after unlinking')
.option(
'-n, --namespace <namespace>',
'Package namespace to restore',
'@parcel',
)
.option(
'-g, --node-modules-globs <globs...>',
'Locations where node_modules should be unlinked in the app',
'node_modules',
)
.action((packageRoot, options) => {
if (options.dryRun) console.log('Dry run...');
unlink({
appRoot: process.cwd(),
namespace: options.namespace,
nodeModulesGlobs: Array.isArray(options.nodeModulesGlobs)
? options.nodeModulesGlobs
: [options.nodeModulesGlobs],
dryRun: options.dryRun,
forceInstall: options.forceInstall,
log: console.log,
});
console.log('馃帀 Unlinking successful');
})
.parse();