@@ -9,7 +9,7 @@ const fs = require('fs');
99const cipher = require ( './cipher' ) ;
1010const authStore = path . resolve ( __dirname , cipher . astore ) ;
1111const authBase = path . basename ( path . dirname ( authStore ) ) ;
12- const { Writable } = require ( 'stream' ) ;
12+ const { Writable} = require ( 'stream' ) ;
1313
1414const mutableStdout = new Writable ( {
1515 write ( chunk , encoding , callback ) {
@@ -61,65 +61,65 @@ const saveAuth = (obj, filename) => new Promise((resolve, reject) => {
6161
6262const updateRabbit = ( ) => new Promise ( ( resolve , reject ) => {
6363 question ( 'Update RabbitMQ account?[yes/no]' )
64- . then ( ( answer ) => {
65- answer = answer . toLowerCase ( ) ;
66- if ( answer !== 'y' && answer !== 'yes' ) {
67- resolve ( ) ;
68- return ;
69- }
70- question ( `(${ authBase } ) Enter username of rabbitmq: ` )
71- . then ( ( username ) => {
72- question ( `(${ authBase } ) Enter password of rabbitmq: ` )
73- . then ( ( password ) => {
74- mutableStdout . muted = false ;
75- saveAuth ( { rabbit : { username, password } } , authStore )
76- . then ( resolve )
77- . catch ( reject ) ;
64+ . then ( ( answer ) => {
65+ answer = answer . toLowerCase ( ) ;
66+ if ( answer !== 'y' && answer !== 'yes' ) {
67+ resolve ( ) ;
68+ return ;
69+ }
70+ question ( `(${ authBase } ) Enter username of rabbitmq: ` )
71+ . then ( ( username ) => {
72+ question ( `(${ authBase } ) Enter password of rabbitmq: ` )
73+ . then ( ( password ) => {
74+ mutableStdout . muted = false ;
75+ saveAuth ( { rabbit : { username, password} } , authStore )
76+ . then ( resolve )
77+ . catch ( reject ) ;
78+ } ) ;
79+ mutableStdout . muted = true ;
7880 } ) ;
79- mutableStdout . muted = true ;
80- } ) ;
81- } ) ;
81+ } ) ;
8282} ) ;
8383
8484const updateMongo = ( ) => new Promise ( ( resolve , reject ) => {
8585 question ( 'Update MongoDB account?[yes/no]' )
86- . then ( ( answer ) => {
87- answer = answer . toLowerCase ( ) ;
88- if ( answer !== 'y' && answer !== 'yes' ) {
89- resolve ( ) ;
90- return ;
91- }
92- question ( `(${ authBase } ) Enter username of mongodb: ` )
93- . then ( ( username ) => {
94- question ( `(${ authBase } ) Enter password of mongodb: ` )
95- . then ( ( password ) => {
96- mutableStdout . muted = false ;
97- saveAuth ( { mongo : { username, password } } , authStore )
98- . then ( resolve )
99- . catch ( reject ) ;
86+ . then ( ( answer ) => {
87+ answer = answer . toLowerCase ( ) ;
88+ if ( answer !== 'y' && answer !== 'yes' ) {
89+ resolve ( ) ;
90+ return ;
91+ }
92+ question ( `(${ authBase } ) Enter username of mongodb: ` )
93+ . then ( ( username ) => {
94+ question ( `(${ authBase } ) Enter password of mongodb: ` )
95+ . then ( ( password ) => {
96+ mutableStdout . muted = false ;
97+ saveAuth ( { mongo : { username, password} } , authStore )
98+ . then ( resolve )
99+ . catch ( reject ) ;
100+ } ) ;
101+ mutableStdout . muted = true ;
100102 } ) ;
101- mutableStdout . muted = true ;
102- } ) ;
103- } ) ;
103+ } ) ;
104104} ) ;
105105
106106const updateInternal = ( ) => new Promise ( ( resolve , reject ) => {
107107 question ( 'Update internal passphrase?[yes/no]' )
108- . then ( ( answer ) => {
109- answer = answer . toLowerCase ( ) ;
110- if ( answer !== 'y' && answer !== 'yes' ) {
111- resolve ( ) ;
112- return ;
113- }
114- question ( `(${ authBase } ) Enter internal passphrase: ` )
115- . then ( ( passphrase ) => {
116- mutableStdout . muted = false ;
117- saveAuth ( { internalPass : passphrase } , authStore )
118- . then ( resolve )
119- . catch ( reject ) ;
120- } ) ;
121- mutableStdout . muted = true ;
122- } ) ;
108+ . then ( ( answer ) => {
109+ answer = answer . toLowerCase ( ) ;
110+ if ( answer !== 'y' && answer !== 'yes' ) {
111+ resolve ( ) ;
112+ return ;
113+ }
114+ question ( `(${ authBase } ) Enter internal passphrase: ` )
115+ . then ( ( passphrase ) => {
116+ mutableStdout . muted = false ;
117+ saveAuth ( { internalPass : passphrase } , authStore )
118+ . then ( resolve )
119+ . catch ( reject ) ;
120+ } ) ;
121+ mutableStdout . muted = true ;
122+ } ) ;
123123} ) ;
124124
125125const options = { } ;
@@ -138,22 +138,22 @@ const parseArgs = () => {
138138 options . mongo = true ;
139139 }
140140 return Promise . resolve ( ) ;
141- }
141+ } ;
142142
143143parseArgs ( )
144- . then ( ( ) => {
145- if ( options . rabbit ) {
146- return updateRabbit ( ) ;
147- }
148- } )
149- . then ( ( ) => {
150- if ( options . mongo ) {
151- return updateMongo ( ) ;
152- }
153- } )
154- . then ( ( ) => {
155- if ( options . internal ) {
156- return updateInternal ( ) ;
157- }
158- } )
159- . finally ( ( ) => readline . close ( ) ) ;
144+ . then ( ( ) => {
145+ if ( options . rabbit ) {
146+ return updateRabbit ( ) ;
147+ }
148+ } )
149+ . then ( ( ) => {
150+ if ( options . mongo ) {
151+ return updateMongo ( ) ;
152+ }
153+ } )
154+ . then ( ( ) => {
155+ if ( options . internal ) {
156+ return updateInternal ( ) ;
157+ }
158+ } )
159+ . finally ( ( ) => readline . close ( ) ) ;
0 commit comments