File tree 3 files changed +32
-9
lines changed
3 files changed +32
-9
lines changed Original file line number Diff line number Diff line change @@ -36,9 +36,9 @@ export default class PluginsUninstall extends Command {
36
36
if ( flags . verbose ) this . plugins . verbose = true
37
37
if ( argv . length === 0 ) argv . push ( '.' )
38
38
for ( const plugin of argv ) {
39
- const friendly = this . plugins . friendlyName ( plugin )
39
+ const friendly = this . removeTags ( this . plugins . friendlyName ( plugin ) )
40
40
cli . action . start ( `Uninstalling ${ friendly } ` )
41
- const unfriendly = await this . plugins . hasPlugin ( plugin )
41
+ const unfriendly = await this . plugins . hasPlugin ( this . removeTags ( plugin ) )
42
42
if ( ! unfriendly ) {
43
43
const p = this . config . plugins . find ( p => p . name === plugin ) as Plugin | undefined
44
44
if ( p ) {
@@ -51,4 +51,19 @@ export default class PluginsUninstall extends Command {
51
51
}
52
52
}
53
53
/* eslint-enable no-await-in-loop */
54
+
55
+ private removeTags ( plugin : string ) {
56
+ if ( plugin . includes ( '@' ) ) {
57
+ const chunked = plugin . split ( '@' )
58
+ const last = chunked [ chunked . length - 1 ]
59
+
60
+ if ( ! last . includes ( '/' ) && chunked . length > 1 ) {
61
+ chunked . pop ( )
62
+ }
63
+
64
+ return chunked . join ( '@' )
65
+ }
66
+
67
+ return plugin
68
+ }
54
69
}
Original file line number Diff line number Diff line change @@ -181,13 +181,10 @@ export default class Plugins {
181
181
182
182
async hasPlugin ( name : string ) {
183
183
const list = await this . list ( )
184
- return list . find ( p => {
185
- if ( this . friendlyName ( p . name ) === this . friendlyName ( name ) ) return true
186
- if ( p . type === 'link' ) {
187
- if ( path . resolve ( p . root ) === path . resolve ( name ) ) return true
188
- }
189
- return false
190
- } )
184
+ const friendly = list . find ( p => this . friendlyName ( p . name ) === this . friendlyName ( name ) )
185
+ const unfriendly = list . find ( p => this . unfriendlyName ( p . name ) === this . unfriendlyName ( name ) )
186
+ const link = list . find ( p => p . type === 'link' && path . resolve ( p . root ) === path . resolve ( name ) )
187
+ return friendly ?? unfriendly ?? link ?? false
191
188
}
192
189
193
190
async yarnNodeVersion ( ) : Promise < string | undefined > {
Original file line number Diff line number Diff line change @@ -15,6 +15,17 @@ describe('command', () => {
15
15
. do ( output => expect ( output . stdout ) . to . equal ( 'no plugins installed\n' ) )
16
16
. it ( 'installs and uninstalls @oclif/example-plugin-ts' )
17
17
18
+ test
19
+ . command ( [ 'plugins:install' , '@oclif/example-plugin-ts@latest' ] , { reset : true } )
20
+ . stdout ( )
21
+ . command ( [ 'plugins' ] , { reset : true } )
22
+ . do ( output => expect ( output . stdout ) . to . contain ( '@oclif/example-plugin-ts' ) )
23
+ . command ( [ 'plugins:uninstall' , '@oclif/example-plugin-ts@latest' ] , { reset : true } )
24
+ . stdout ( )
25
+ . command ( [ 'plugins' ] , { reset : true } )
26
+ . do ( output => expect ( output . stdout ) . to . equal ( 'no plugins installed\n' ) )
27
+ . it ( 'installs and uninstalls @oclif/example-plugin-ts with tags' )
28
+
18
29
test
19
30
. command ( [ 'plugins:install' , 'aliasme' ] , { reset : true } )
20
31
. stdout ( )
You can’t perform that action at this time.
0 commit comments