@@ -12,7 +12,7 @@ import { getDefaultAgent, getGlobalAgent } from './config'
12
12
import type { DetectOptions } from './detect'
13
13
import { detect } from './detect'
14
14
import { getVoltaPrefix , remove } from './utils'
15
- import { UnsupportedCommand } from './parse'
15
+ import { UnsupportedCommand , getCommand } from './parse'
16
16
17
17
const DEBUG_SIGN = '?'
18
18
@@ -84,8 +84,9 @@ export async function run(fn: Runner, args: string[], options: DetectOptions = {
84
84
args . splice ( 0 , 2 )
85
85
}
86
86
87
- if ( args . length === 1 && ( args [ 0 ] ?. toLowerCase ( ) === '-v' ) ) {
88
- const getV = ( a : string , o ?: ExecaOptions ) => execaCommand ( `${ a } -v` , o ) . then ( e => e . stdout ) . then ( e => e . startsWith ( 'v' ) ? e : `v${ e } ` )
87
+ if ( args . length === 1 && ( args [ 0 ] ?. toLowerCase ( ) === '-v' || args [ 0 ] === '--version' ) ) {
88
+ const getCmd = ( a : Agent ) => agents . includes ( a ) ? getCommand ( a , 'agent' , [ '-v' ] ) : `${ a } -v`
89
+ const getV = ( a : string , o ?: ExecaOptions ) => execaCommand ( getCmd ( a as Agent ) , o ) . then ( e => e . stdout ) . then ( e => e . startsWith ( 'v' ) ? e : `v${ e } ` )
89
90
const globalAgentPromise = getGlobalAgent ( )
90
91
const globalAgentVersionPromise = globalAgentPromise . then ( getV )
91
92
const agentPromise = detect ( { ...options , cwd } ) . then ( a => a || '' )
@@ -112,13 +113,14 @@ export async function run(fn: Runner, args: string[], options: DetectOptions = {
112
113
if ( args . length === 1 && [ '-h' , '--help' ] . includes ( args [ 0 ] ) ) {
113
114
const dash = c . dim ( '-' )
114
115
console . log ( c . green ( c . bold ( '@antfu/ni' ) ) + c . dim ( ` use the right package manager v${ version } \n` ) )
115
- console . log ( `ni ${ dash } install` )
116
- console . log ( `nr ${ dash } run` )
117
- console . log ( `nlx ${ dash } execute` )
118
- console . log ( `nu ${ dash } upgrade` )
119
- console . log ( `nun ${ dash } uninstall` )
120
- console . log ( `nci ${ dash } clean install` )
121
- console . log ( `na ${ dash } agent alias` )
116
+ console . log ( `ni ${ dash } install` )
117
+ console . log ( `nr ${ dash } run` )
118
+ console . log ( `nlx ${ dash } execute` )
119
+ console . log ( `nu ${ dash } upgrade` )
120
+ console . log ( `nun ${ dash } uninstall` )
121
+ console . log ( `nci ${ dash } clean install` )
122
+ console . log ( `na ${ dash } agent alias` )
123
+ console . log ( `ni -v ${ dash } show used agent` )
122
124
console . log ( c . yellow ( '\ncheck https://github.com/antfu/ni for more documentation.' ) )
123
125
return
124
126
}
0 commit comments