-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflags.ts
More file actions
85 lines (76 loc) · 2.12 KB
/
Copy pathflags.ts
File metadata and controls
85 lines (76 loc) · 2.12 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* @file Pnpm CLI flag predicates. pnpm reuses npm's `--loglevel` flag verbatim,
* so isPnpmLoglevelFlag is an explicit alias of isNpmLoglevelFlag rather than
* a separate implementation.
*/
import { SetCtor } from '../../../primordials/map-set'
import { isNpmLoglevelFlag } from '../npm/flags'
const pnpmIgnoreScriptsFlags = new SetCtor([
'--ignore-scripts',
'--no-ignore-scripts',
])
const pnpmFrozenLockfileFlags = new SetCtor([
'--frozen-lockfile',
'--no-frozen-lockfile',
])
const pnpmInstallCommands = new SetCtor(['install', 'i'])
/**
* Check if a command argument is a pnpm frozen-lockfile flag.
*
* @example
* ;```typescript
* isPnpmFrozenLockfileFlag('--frozen-lockfile') // true
* isPnpmFrozenLockfileFlag('--no-frozen-lockfile') // true
* isPnpmFrozenLockfileFlag('--save') // false
* ```
*/
export function isPnpmFrozenLockfileFlag(cmdArg: string): boolean {
return pnpmFrozenLockfileFlags.has(cmdArg)
}
/**
* Check if a command argument is a pnpm ignore-scripts flag.
*
* @example
* ;```typescript
* isPnpmIgnoreScriptsFlag('--ignore-scripts') // true
* isPnpmIgnoreScriptsFlag('--no-ignore-scripts') // true
* isPnpmIgnoreScriptsFlag('--save') // false
* ```
*/
export function isPnpmIgnoreScriptsFlag(cmdArg: string): boolean {
return pnpmIgnoreScriptsFlags.has(cmdArg)
}
/**
* Check if a command argument is a pnpm install command.
*
* @example
* ;```typescript
* isPnpmInstallCommand('install') // true
* isPnpmInstallCommand('i') // true
* isPnpmInstallCommand('run') // false
* ```
*/
export function isPnpmInstallCommand(cmdArg: string): boolean {
return pnpmInstallCommands.has(cmdArg)
}
/**
* Alias for isNpmLoglevelFlag — pnpm uses the same `--loglevel` surface.
*/
export const isPnpmLoglevelFlag = isNpmLoglevelFlag
// Internal: commands that support --ignore-scripts in pnpm.
// Installation-related: install, add, update, remove, link, unlink, import, rebuild.
export const PNPM_INSTALL_LIKE_COMMANDS = new SetCtor([
'install',
'i',
'add',
'update',
'up',
'remove',
'rm',
'link',
'ln',
'unlink',
'import',
'rebuild',
'rb',
])