@@ -31,29 +31,9 @@ module.exports = function (program) {
3131 // Prompt to the user
3232 inquirer . prompt ( questions )
3333 . then ( ( answers ) => {
34- // setting email
35- if ( answers . useEmail ) {
36- answers . email = {
37- host : answers [ 'email-host' ] ,
38- port : answers [ 'email-port' ] ,
39- secure : true ,
40- auth : {
41- user : answers [ 'email-auth-user' ] ,
42- pass : answers [ 'email-auth-pass' ]
43- }
44- }
45- delete answers [ 'email-host' ]
46- delete answers [ 'email-port' ]
47- delete answers [ 'email-auth-user' ]
48- delete answers [ 'email-auth-pass' ]
49- }
50-
51- // clean answers
52- Object . keys ( answers ) . forEach ( ( answer ) => {
53- if ( answer . startsWith ( 'use' ) ) {
54- delete answers [ answer ]
55- }
56- } )
34+ manipulateEmailSection ( answers )
35+ manipulateServerSection ( answers )
36+ cleanupAnswers ( answers )
5737
5838 // write config file
5939 const config = JSON . stringify ( camelize ( answers ) , null , ' ' )
@@ -71,3 +51,44 @@ module.exports = function (program) {
7151 } )
7252 } )
7353}
54+
55+ function cleanupAnswers ( answers ) {
56+ // clean answers
57+ Object . keys ( answers ) . forEach ( ( answer ) => {
58+ if ( answer . startsWith ( 'use' ) ) {
59+ delete answers [ answer ]
60+ }
61+ } )
62+ }
63+
64+ function manipulateEmailSection ( answers ) {
65+ // setting email
66+ if ( answers . useEmail ) {
67+ answers . email = {
68+ host : answers [ 'email-host' ] ,
69+ port : answers [ 'email-port' ] ,
70+ secure : true ,
71+ auth : {
72+ user : answers [ 'email-auth-user' ] ,
73+ pass : answers [ 'email-auth-pass' ]
74+ }
75+ }
76+ delete answers [ 'email-host' ]
77+ delete answers [ 'email-port' ]
78+ delete answers [ 'email-auth-user' ]
79+ delete answers [ 'email-auth-pass' ]
80+ }
81+ }
82+
83+ function manipulateServerSection ( answers ) {
84+ answers . server = {
85+ name : answers [ 'server-name' ] ,
86+ description : answers [ 'server-description' ] ,
87+ logo : answers [ 'server-logo' ]
88+ }
89+ Object . keys ( answers ) . forEach ( ( answer ) => {
90+ if ( answer . startsWith ( 'server-' ) ) {
91+ delete answers [ answer ]
92+ }
93+ } )
94+ }
0 commit comments