File tree 1 file changed +26
-1
lines changed
1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 3
3
'use strict' ;
4
4
5
5
var path = require ( 'path' ) ;
6
+ var fs = require ( 'fs' ) ;
6
7
var Liftoff = require ( 'liftoff' ) ;
7
8
var argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) ) ;
8
9
var v8flags = require ( 'v8flags' ) ;
@@ -37,6 +38,18 @@ function run(env) {
37
38
displayHelpScreen ( ) ;
38
39
process . exit ( 0 ) ;
39
40
}
41
+
42
+ if ( argv . init || argv . i ) {
43
+ return createInitPlopfile ( function ( err ) {
44
+ if ( err ) {
45
+ console . log ( err ) ;
46
+
47
+ process . exit ( 1 ) ;
48
+ }
49
+
50
+ process . exit ( 0 ) ;
51
+ } ) ;
52
+ }
40
53
41
54
// handle request for version number
42
55
if ( argv . version || argv . v ) {
@@ -85,6 +98,18 @@ function run(env) {
85
98
'\t\t-v, --version\t\tPrint current version\n' ) ;
86
99
}
87
100
101
+ function createInitPlopfile ( callback ) {
102
+ var initString = 'module.exports = function (plop) {\n\n' +
103
+ '\tplop.setGenerator(\'basics\', {\n' +
104
+ '\t\tdescription: \'this is a skeleton plopfile\',\n' +
105
+ '\t\tprompts: [],\n' +
106
+ '\t\tactions: []\n' +
107
+ '\t});\n\n' +
108
+ '};' ;
109
+
110
+ fs . writeFile ( env . cwd + '/plopfile.js' , initString , callback ) ;
111
+ }
112
+
88
113
}
89
114
90
115
function go ( generator ) {
@@ -102,4 +127,4 @@ function go(generator) {
102
127
console . error ( '[ERROR]' . red , err . message , err . stack ) ;
103
128
process . exit ( 1 ) ;
104
129
} ) ;
105
- }
130
+ }
You can’t perform that action at this time.
0 commit comments