Skip to content

Commit 6576f29

Browse files
committed
fixup! fix the tests too
1 parent 5f6beb8 commit 6576f29

File tree

4 files changed

+452
-538
lines changed

4 files changed

+452
-538
lines changed

lib/commands/access.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class Access extends BaseCommand {
7474
case 'revoke':
7575
return []
7676
default:
77+
console.log('throwing')
7778
throw new Error(argv[2] + ' not recognized')
7879
}
7980
}

lib/commands/completion.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,10 @@ class Completion extends BaseCommand {
180180
// Ie, returning ['a', 'b c', ['d', 'e']] would allow it to expand
181181
// to: 'a', 'b c', or 'd' 'e'
182182
wrap (opts, compls) {
183-
if (!Array.isArray(compls)) {
184-
compls = compls ? [compls] : []
185-
}
186-
187-
compls = compls.map(c =>
188-
Array.isArray(c) ? c.map(escape).join(' ') : escape(c))
183+
// TODO this was dead code, leaving it in case we find some command we
184+
// forgot that requires this. if so *that command should fix its
185+
// completions*
186+
// compls = compls.map(w => !/\s+/.test(w) ? w : '\'' + w + '\'')
189187

190188
if (opts.partialWord) {
191189
compls = compls.filter(c => c.startsWith(opts.partialWord))
@@ -246,9 +244,6 @@ const dumpScript = async () => {
246244
const unescape = w => w.charAt(0) === '\'' ? w.replace(/^'|'$/g, '')
247245
: w.replace(/\\ /g, ' ')
248246

249-
const escape = w => !/\s+/.test(w) ? w
250-
: '\'' + w + '\''
251-
252247
// the current word has a dash. Return the config names,
253248
// with the same number of dashes as the current word has.
254249
const configCompl = opts => {
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
/* IMPORTANT
2+
* This snapshot file is auto-generated, but designed for humans.
3+
* It should be checked into source control and tracked carefully.
4+
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
5+
* Make sure to inspect the output below. Do not ignore changes!
6+
*/
7+
'use strict'
8+
exports[`test/lib/commands/completion.js TAP completion --no- flags > flags 1`] = `
9+
Array [
10+
Array [
11+
String(
12+
--no-version
13+
--no-versions
14+
),
15+
],
16+
]
17+
`
18+
19+
exports[`test/lib/commands/completion.js TAP completion commands with no completion > no results 1`] = `
20+
Array []
21+
`
22+
23+
exports[`test/lib/commands/completion.js TAP completion completion cannot complete options that take a value in mid-command > does not try to complete option arguments in the middle of a command 1`] = `
24+
Array []
25+
`
26+
27+
exports[`test/lib/commands/completion.js TAP completion completion completion > both shells 1`] = `
28+
Array []
29+
`
30+
31+
exports[`test/lib/commands/completion.js TAP completion completion completion no known shells > no responses 1`] = `
32+
Array []
33+
`
34+
35+
exports[`test/lib/commands/completion.js TAP completion completion completion wrong word count > no responses 1`] = `
36+
Array []
37+
`
38+
39+
exports[`test/lib/commands/completion.js TAP completion completion of invalid command name does nothing > no results 1`] = `
40+
Array []
41+
`
42+
43+
exports[`test/lib/commands/completion.js TAP completion double dashes escape from flag completion > full command list 1`] = `
44+
Array [
45+
Array [
46+
String(
47+
ci
48+
install-ci-test
49+
install
50+
install-test
51+
uninstall
52+
cache
53+
config
54+
set
55+
get
56+
update
57+
outdated
58+
prune
59+
pack
60+
find-dupes
61+
dedupe
62+
hook
63+
rebuild
64+
link
65+
publish
66+
star
67+
stars
68+
unstar
69+
adduser
70+
login
71+
logout
72+
unpublish
73+
owner
74+
access
75+
team
76+
deprecate
77+
shrinkwrap
78+
token
79+
profile
80+
audit
81+
fund
82+
org
83+
help
84+
ls
85+
ll
86+
search
87+
view
88+
init
89+
version
90+
edit
91+
explore
92+
docs
93+
repo
94+
bugs
95+
root
96+
prefix
97+
bin
98+
whoami
99+
diff
100+
dist-tag
101+
ping
102+
pkg
103+
test
104+
stop
105+
start
106+
restart
107+
run-script
108+
set-script
109+
completion
110+
doctor
111+
exec
112+
explain
113+
un
114+
rb
115+
list
116+
ln
117+
create
118+
i
119+
it
120+
cit
121+
up
122+
c
123+
s
124+
se
125+
tst
126+
t
127+
ddp
128+
v
129+
run
130+
clean-install
131+
clean-install-test
132+
x
133+
why
134+
la
135+
verison
136+
ic
137+
innit
138+
in
139+
ins
140+
inst
141+
insta
142+
instal
143+
isnt
144+
isnta
145+
isntal
146+
install-clean
147+
isntall-clean
148+
hlep
149+
dist-tags
150+
upgrade
151+
udpate
152+
login
153+
add-user
154+
author
155+
home
156+
issues
157+
info
158+
show
159+
find
160+
add
161+
unlink
162+
remove
163+
rm
164+
r
165+
rum
166+
sit
167+
urn
168+
ogr
169+
),
170+
],
171+
]
172+
`
173+
174+
exports[`test/lib/commands/completion.js TAP completion filtered subcommands > filtered subcommands 1`] = `
175+
Array [
176+
Array [
177+
"public",
178+
],
179+
]
180+
`
181+
182+
exports[`test/lib/commands/completion.js TAP completion flags > flags 1`] = `
183+
Array [
184+
Array [
185+
String(
186+
--version
187+
--versions
188+
--viewer
189+
--verbose
190+
--v
191+
),
192+
],
193+
]
194+
`
195+
196+
exports[`test/lib/commands/completion.js TAP completion multiple command names > multiple command names 1`] = `
197+
Array [
198+
Array [
199+
String(
200+
adduser
201+
access
202+
audit
203+
add-user
204+
author
205+
add
206+
),
207+
],
208+
]
209+
`
210+
211+
exports[`test/lib/commands/completion.js TAP completion single command name > single command name 1`] = `
212+
Array [
213+
Array [
214+
"config",
215+
],
216+
]
217+
`
218+
219+
exports[`test/lib/commands/completion.js TAP completion subcommand completion > subcommands 1`] = `
220+
Array [
221+
Array [
222+
String(
223+
public
224+
restricted
225+
grant
226+
revoke
227+
ls-packages
228+
ls-collaborators
229+
edit
230+
2fa-required
231+
2fa-not-required
232+
),
233+
],
234+
]
235+
`
236+
237+
exports[`test/lib/commands/completion.js TAP windows without bash > no output 1`] = `
238+
Array []
239+
`

0 commit comments

Comments
 (0)