File tree 2 files changed +7
-0
lines changed
2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,18 @@ const inquirer = require('inquirer')
6
6
const Creator = require ( './Creator' )
7
7
const clearConsole = require ( './util/clearConsole' )
8
8
const { error, stopSpinner } = require ( '@vue/cli-shared-utils' )
9
+ const validateProjectName = require ( 'validate-npm-package-name' )
9
10
10
11
async function create ( projectName , options ) {
11
12
const inCurrent = projectName === '.'
12
13
const name = inCurrent ? path . relative ( '../' , process . cwd ( ) ) : projectName
13
14
const targetDir = path . resolve ( projectName || '.' )
14
15
16
+ if ( ! validateProjectName ( projectName ) . validForNewPackages ) {
17
+ console . error ( chalk . red ( `Could not be created because ${ projectName } is an invalid name.` ) )
18
+ process . exit ( 1 )
19
+ }
20
+
15
21
if ( fs . existsSync ( targetDir ) ) {
16
22
if ( options . force ) {
17
23
rimraf . sync ( targetDir )
Original file line number Diff line number Diff line change 51
51
"rimraf" : " ^2.6.2" ,
52
52
"semver" : " ^5.4.1" ,
53
53
"slash" : " ^1.0.0" ,
54
+ "validate-npm-package-name" : " ^3.0.0" ,
54
55
"yaml-front-matter" : " ^3.4.1"
55
56
},
56
57
"engines" : {
You can’t perform that action at this time.
0 commit comments