blob: 23e89ddce698bfb469ebe721c99e8e3184f872d8 (
plain)
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
52
53
54
55
56
57
58
59
|
const options = module.exports = {
path: undefined,
cache: `${process.env.HOME}/.npm/_cacache`,
_: [],
}
for (const arg of process.argv.slice(2)) {
if (/^--add=/.test(arg)) {
options.add = options.add || []
options.add.push(arg.substr('--add='.length))
} else if (/^--rm=/.test(arg)) {
options.rm = options.rm || []
options.rm.push(arg.substr('--rm='.length))
} else if (arg === '--global') {
options.global = true
} else if (arg === '--global-style') {
options.globalStyle = true
} else if (arg === '--prefer-dedupe') {
options.preferDedupe = true
} else if (arg === '--legacy-peer-deps') {
options.legacyPeerDeps = true
} else if (arg === '--force') {
options.force = true
} else if (arg === '--update-all') {
options.update = options.update || {}
options.update.all = true
} else if (/^--update=/.test(arg)) {
options.update = options.update || {}
options.update.names = options.update.names || []
options.update.names.push(arg.substr('--update='.length))
} else if (/^--omit=/.test(arg)) {
options.omit = options.omit || []
options.omit.push(arg.substr('--omit='.length))
} else if (/^--before=/.test(arg)) {
options.before = new Date(arg.substr('--before='.length))
} else if (/^-w.+/.test(arg)) {
options.workspaces = options.workspaces || []
options.workspaces.push(arg.replace(/^-w/, ''))
} else if (/^--workspace=/.test(arg)) {
options.workspaces = options.workspaces || []
options.workspaces.push(arg.replace(/^--workspace=/, ''))
} else if (/^--[^=]+=/.test(arg)) {
const [key, ...v] = arg.replace(/^--/, '').split('=')
const val = v.join('=')
options[key] = val === 'false' ? false : val === 'true' ? true : val
} else if (/^--.+/.test(arg)) {
options[arg.replace(/^--/, '')] = true
} else if (options.path === undefined) {
options.path = arg
} else {
options._.push(arg)
}
}
if (options.path === undefined) {
options.path = '.'
}
console.error(options)
|