File tree Expand file tree Collapse file tree 4 files changed +15
-10
lines changed Expand file tree Collapse file tree 4 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ let data = require('./../data');
22
33module . exports = `{
44 "name": "` + data . projectName + `",
5- "version": "` + data . version + ` ",
5+ "version": "1.0.0 ",
66 "description": "` + data . description + `",
77 "main": "` + data . entry_point + `",
88 "scripts": {
Original file line number Diff line number Diff line change @@ -22,8 +22,10 @@ function createdirectory(dirName) {
2222 let suffix ;
2323 while ( true ) {
2424 try {
25- fs . mkdirSync ( dirName + ( suffix ? suffix : '' ) ) ;
26- process . chdir ( dirName + ( suffix ? suffix : '' ) ) ;
25+ let projectName = dirName + ( suffix ? suffix : '' ) ;
26+ fs . mkdirSync ( projectName ) ;
27+ process . chdir ( projectName ) ;
28+ data . projectName = projectName ;
2729 } catch ( err ) {
2830 if ( err . code === 'EEXIST' ) {
2931 suffix = suffix ? suffix + 1 : 1 ;
Original file line number Diff line number Diff line change @@ -11,10 +11,10 @@ const readA = readline.createInterface({
1111
1212module . exports = ( cb ) => {
1313 let q1 = ( ) => readA . question ( 'project name: (' + utils . getCurDirName ( ) + ') ' ,
14- ( answer ) => { if ( answer ) data . projectName = answer ; q2 ( ) ; } ) ;
14+ ( answer ) => { if ( answer ) data . projectName = answer ; q3 ( ) ; } ) ;
1515
16- let q2 = ( ) => readA . question ( 'version: (1.0.0) ' ,
17- ( answer ) => { if ( answer ) data . version = answer ; q3 ( ) ; } ) ;
16+ // let q2 = () => readA.question('version: (1.0.0) ',
17+ // (answer) => { if (answer) data.version = answer; q3(); });
1818
1919 let q3 = ( ) => readA . question ( 'description: (A simple node based API) ' ,
2020 ( answer ) => { if ( answer ) data . description = answer ; q4 ( ) ; } ) ;
Original file line number Diff line number Diff line change 11'use strict'
22
33const path = require ( 'path' ) ;
4+ const data = require ( './../constants/data' ) ;
45module . exports = {
56 getCurDirName : ( ) => {
67 return process . cwd ( ) . split ( path . sep ) . slice ( - 1 ) ;
@@ -13,11 +14,13 @@ module.exports = {
1314 detached : true
1415 } ) ;
1516 child . stdout . on ( 'data' , function ( buffer ) {
16- console . log ( '\x1b[33m' + buffer . toString ( ) ) ;
17+ console . log ( '\x1b[33m' + buffer . toString ( ) + '\x1b[0m' ) ;
1718 } ) ;
1819
19-
20- child . unref ( )
21- console . log ( '\nRunning' + '\x1b[31m npm install\x1b[0m' + ' for you\n' ) ;
20+ child . stdout . on ( 'close' , function ( ) {
21+ console . log ( 'Your project ' + data . projectName + ' is ready.' ) ;
22+ console . log ( 'Run command' + '\x1b[31m npm start\x1b[0m' + ' to start the project.' ) ;
23+ } ) ;
24+ console . log ( '\nRunning' + '\x1b[31m npm install\x1b[0m' + ' for you.\n' ) ;
2225 } ,
2326}
You can’t perform that action at this time.
0 commit comments