File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 100100 "elegant-spinner" : " ^1.0.1" ,
101101 "log-update" : " ^2.3.0" ,
102102 "shelljs" : " ^0.8.2" ,
103+ "validate-npm-package-name" : " ^3.0.0" ,
103104 "writefile" : " ^0.2.8"
104105 },
105106 "devDependencies" : {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import chalk from 'chalk';
33import elegantSpinner from 'elegant-spinner' ;
44import logUpdate from 'log-update' ;
55import variants from '../../variants.json' ;
6+ import validate from 'validate-npm-package-name' ;
67
78require ( 'shelljs/global' ) ;
89
@@ -23,6 +24,16 @@ if (program.args.length > 1) {
2324 exit ( 1 ) ;
2425}
2526
27+ const validationResult = validate ( program . args [ 0 ] ) ;
28+ if ( ! validationResult . validForNewPackages ) {
29+ console . error (
30+ `Could not create a project called ${ chalk . red (
31+ `"${ program . args [ 0 ] } "`
32+ ) } because of npm naming restrictions:`
33+ ) ;
34+ exit ( 1 ) ;
35+ }
36+
2637if ( program . args . length === 1 ) {
2738 if ( test ( '-d' , program . args [ 0 ] ) ) {
2839 console . log ( chalk . red ( `${ program . args [ 0 ] } directory already exits! Please choose some another name!!!` ) ) ;
You can’t perform that action at this time.
0 commit comments