1- const path = require ( 'path' ) ;
2- const fs = require ( 'fs' ) ;
1+ const path = require ( 'path' )
2+ const fs = require ( 'fs' )
33const {
44 sortDependencies,
55 installDependencies,
66 runLintFix,
7- printMessage
7+ printMessage,
88} = require ( './utils' )
99
1010module . exports = {
1111 helpers : {
12- if_or : function ( v1 , v2 , options ) {
12+ if_or : function ( v1 , v2 , options ) {
1313 if ( v1 || v2 ) {
14- return options . fn ( this ) ;
14+ return options . fn ( this )
1515 }
1616
17- return options . inverse ( this ) ;
18- }
17+ return options . inverse ( this )
18+ } ,
1919 } ,
2020 prompts : {
2121 name : {
2222 type : 'string' ,
2323 required : true ,
24- message : 'Project name'
24+ message : 'Project name' ,
2525 } ,
2626 description : {
2727 type : 'string' ,
2828 required : false ,
2929 message : 'Project description' ,
30- default : 'A Vue.js project'
30+ default : 'A Vue.js project' ,
3131 } ,
3232 author : {
3333 type : 'string' ,
34- message : 'Author'
34+ message : 'Author' ,
3535 } ,
3636 build : {
3737 type : 'list' ,
@@ -40,22 +40,23 @@ module.exports = {
4040 {
4141 name : 'Runtime + Compiler: recommended for most users' ,
4242 value : 'standalone' ,
43- short : 'standalone'
43+ short : 'standalone' ,
4444 } ,
4545 {
46- name : 'Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere' ,
46+ name :
47+ 'Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere' ,
4748 value : 'runtime' ,
48- short : 'runtime'
49- }
50- ]
49+ short : 'runtime' ,
50+ } ,
51+ ] ,
5152 } ,
5253 router : {
5354 type : 'confirm' ,
54- message : 'Install vue-router?'
55+ message : 'Install vue-router?' ,
5556 } ,
5657 lint : {
5758 type : 'confirm' ,
58- message : 'Use ESLint to lint your code?'
59+ message : 'Use ESLint to lint your code?' ,
5960 } ,
6061 lintConfig : {
6162 when : 'lint' ,
@@ -65,23 +66,23 @@ module.exports = {
6566 {
6667 name : 'Standard (https://github.com/standard/standard)' ,
6768 value : 'standard' ,
68- short : 'Standard'
69+ short : 'Standard' ,
6970 } ,
7071 {
7172 name : 'Airbnb (https://github.com/airbnb/javascript)' ,
7273 value : 'airbnb' ,
73- short : 'Airbnb'
74+ short : 'Airbnb' ,
7475 } ,
7576 {
7677 name : 'none (configure it yourself)' ,
7778 value : 'none' ,
78- short : 'none'
79- }
80- ]
79+ short : 'none' ,
80+ } ,
81+ ] ,
8182 } ,
8283 unit : {
8384 type : 'confirm' ,
84- message : 'Set up unit tests'
85+ message : 'Set up unit tests' ,
8586 } ,
8687 runner : {
8788 when : 'unit' ,
@@ -91,45 +92,46 @@ module.exports = {
9192 {
9293 name : 'Jest' ,
9394 value : 'jest' ,
94- short : 'jest'
95+ short : 'jest' ,
9596 } ,
9697 {
9798 name : 'Karma and Mocha' ,
9899 value : 'karma' ,
99- short : 'karma'
100+ short : 'karma' ,
100101 } ,
101102 {
102103 name : 'none (configure it yourself)' ,
103104 value : 'noTest' ,
104- short : 'noTest'
105- }
106- ]
105+ short : 'noTest' ,
106+ } ,
107+ ] ,
107108 } ,
108109 e2e : {
109110 type : 'confirm' ,
110- message : 'Setup e2e tests with Nightwatch?'
111+ message : 'Setup e2e tests with Nightwatch?' ,
111112 } ,
112113 autoInstall : {
113114 type : 'list' ,
114- message : 'Should we run `npm install` for you after the project has been created? (recommended)' ,
115+ message :
116+ 'Should we run `npm install` for you after the project has been created? (recommended)' ,
115117 choices : [
116118 {
117119 name : 'Yes, use NPM' ,
118120 value : 'npm' ,
119- short : 'npm'
121+ short : 'npm' ,
120122 } ,
121123 {
122124 name : 'Yes, use Yarn' ,
123125 value : 'yarn' ,
124- short : 'yarn'
126+ short : 'yarn' ,
125127 } ,
126128 {
127129 name : 'No, I will handle that myself' ,
128130 value : false ,
129- short : 'no'
130- }
131- ]
132- }
131+ short : 'no' ,
132+ } ,
133+ ] ,
134+ } ,
133135 } ,
134136 filters : {
135137 '.eslintrc.js' : 'lint' ,
@@ -143,27 +145,28 @@ module.exports = {
143145 'test/unit/specs/index.js' : "unit && runner === 'karma'" ,
144146 'test/unit/setup.js' : "unit && runner === 'jest'" ,
145147 'test/e2e/**/*' : 'e2e' ,
146- 'src/router/**/*' : 'router'
148+ 'src/router/**/*' : 'router' ,
147149 } ,
148- 'complete' : function ( data , { chalk } ) {
149-
150+ complete : function ( data , { chalk } ) {
150151 const green = chalk . green
151152
152153 sortDependencies ( data , green )
153154
154155 const cwd = path . join ( process . cwd ( ) , data . inPlace ? '' : data . destDirName )
155-
156+
156157 if ( data . autoInstall ) {
157158 installDependencies ( cwd , data . autoInstall , green )
158- . then ( ( ) => {
159- return runLintFix ( cwd , data , green )
160- } )
161- . then ( ( ) => {
162- printMessage ( data , green )
163- } )
159+ . then ( ( ) => {
160+ return runLintFix ( cwd , data , green )
161+ } )
162+ . then ( ( ) => {
163+ printMessage ( data , green )
164+ } )
165+ . catch ( e => {
166+ console . log ( chalk . red ( 'Error:' ) , e )
167+ } )
164168 } else {
165169 printMessage ( data , chalk )
166170 }
167-
168- }
169- } ;
171+ } ,
172+ }
0 commit comments