@@ -2,15 +2,10 @@ const getYo = require("yo-reshow");
2
2
const { YoGenerator, YoHelper, commonPrompt } = getYo ( ) ;
3
3
4
4
/**
5
- * Library Generator
5
+ * Library Generator
6
6
*/
7
7
8
8
module . exports = class extends YoGenerator {
9
- constructor ( args , opts ) {
10
- super ( args , opts ) ;
11
- this . argument ( "mainName" , { type : String , required : false } ) ;
12
- }
13
-
14
9
/**
15
10
* Run loop (Life cycle)
16
11
* https://yeoman.io/authoring/running-context.html#the-run-loop
@@ -32,9 +27,8 @@ module.exports = class extends YoGenerator {
32
27
* https://github.com/SBoudrias/Inquirer.js
33
28
*/
34
29
async prompting ( ) {
35
- this . env . options . nodePackageManager = "yarn" ;
36
-
37
30
const {
31
+ handleAnswers,
38
32
mergePromptOrOption,
39
33
promptChainLocator,
40
34
promptChain,
@@ -46,21 +40,14 @@ module.exports = class extends YoGenerator {
46
40
...commonPrompt . author ( this ) ,
47
41
] ;
48
42
49
- const answers = await mergePromptOrOption (
50
- prompts ,
51
- ( nextPrompts ) => promptChain ( promptChainLocator ( nextPrompts ) )
43
+ const answers = await mergePromptOrOption ( prompts , ( nextPrompts ) =>
44
+ promptChain ( promptChainLocator ( nextPrompts ) )
52
45
) ;
53
-
54
- this . mainName = answers . mainName ;
55
- this . payload = {
56
- ...answers ,
57
- mainName : this . mainName ,
58
- description : answers . description || 'TODO: description' ,
59
- keyword : answers . keyword || this . mainName ,
60
- } ;
46
+ handleAnswers ( answers ) ;
61
47
}
62
48
63
49
writing ( ) {
50
+ this . env . options . nodePackageManager = "yarn" ;
64
51
const { cp, chMainName } = YoHelper ( this ) ;
65
52
66
53
// handle change to new folder
@@ -78,7 +65,7 @@ module.exports = class extends YoGenerator {
78
65
end ( ) {
79
66
if ( ! this . options ?. skipInstall ) {
80
67
const { say, onExit } = YoHelper ( this ) ;
81
- onExit ( ( ) => say ( 'Next you could try "npm run build" or "npm run test"' ) ) ;
68
+ onExit ( ( ) => say ( 'Next you could try "npm run build" or "npm run test"' ) ) ;
82
69
}
83
70
}
84
71
} ;
0 commit comments