File tree 4 files changed +8
-6
lines changed
4 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import type {
12
12
import { Command } from './command' ;
13
13
import { generateHelp , Renderers } from './render-help' ;
14
14
import { camelCase } from './utils/convert-case' ;
15
- import { isScriptNamePattern } from './utils/is- script-name' ;
15
+ import { isValidScriptName } from './utils/script-name' ;
16
16
17
17
const { stringify } = JSON ;
18
18
@@ -361,15 +361,15 @@ function cli<
361
361
throw new Error ( 'Options is required' ) ;
362
362
}
363
363
364
- if ( 'name' in options && ( ! options . name || ! isScriptNamePattern . test ( options . name ) ) ) {
364
+ if ( 'name' in options && ( ! options . name || ! isValidScriptName ( options . name ) ) ) {
365
365
throw new Error ( `Invalid script name: ${ stringify ( options . name ) } ` ) ;
366
366
}
367
367
368
368
const potentialCommand = argv [ 0 ] ;
369
369
370
370
if (
371
371
options . commands
372
- && isScriptNamePattern . test ( potentialCommand )
372
+ && isValidScriptName ( potentialCommand )
373
373
) {
374
374
const command = getCommand ( potentialCommand , options . commands ) ;
375
375
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import type {
6
6
ParseArgv ,
7
7
parsedType ,
8
8
} from './types' ;
9
- import { isScriptNamePattern } from './utils/is- script-name' ;
9
+ import { isValidScriptName } from './utils/script-name' ;
10
10
11
11
export type CommandOptions < Parameters = string [ ] > = {
12
12
/**
@@ -61,7 +61,7 @@ export function command<
61
61
throw new Error ( 'Command name is required' ) ;
62
62
}
63
63
64
- if ( ! isScriptNamePattern . test ( name ) ) {
64
+ if ( ! isValidScriptName ( name ) ) {
65
65
throw new Error ( `Invalid command name ${ JSON . stringify ( name ) } . Command names must be one word.` ) ;
66
66
}
67
67
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ export const isValidScriptName = (
2
+ name : string ,
3
+ ) => name . length > 0 && ! name . includes ( ' ' ) ;
You can’t perform that action at this time.
0 commit comments