Skip to content

Commit c51ca5b

Browse files
committed
fix(ssl): ensure ssl setup works using the --sslemail flag
closes #283 - cleanup promise handling in ssl setup
1 parent fb7e4f7 commit c51ca5b

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

extensions/nginx/index.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,23 @@ class NginxExtension extends cli.Extension {
132132
}, {
133133
title: 'Preparing nginx for SSL configuration',
134134
task: (ctx) => {
135-
return argv.sslemail ? Promise.resolve({email: argv.sslemail}) : this.ui.prompt({
136-
name: 'email',
137-
type: 'input',
138-
message: 'Enter your email (used for SSL certificate generation)',
139-
validate: value => Boolean(value) || 'You must supply an email'
140-
}).then((answer) => {
141-
argv.sslemail = answer.email;
135+
let promise;
136+
137+
if (argv.sslemail) {
138+
promise = Promise.resolve(argv.sslemail);
139+
} else {
140+
promise = this.ui.prompt({
141+
name: 'email',
142+
type: 'input',
143+
message: 'Enter your email (used for SSL certificate generation)',
144+
validate: value => Boolean(value) || 'You must supply an email'
145+
}).then(answer => { argv.sslemail = answer.email; });
146+
}
142147

143-
ctx.ssl = {};
148+
return promise.then(() => {
149+
return Promise.fromCallback((cb) => NginxConfFile.create(nginxConfPath, cb)).then((conf) => {
150+
ctx.ssl = {};
144151

145-
return Promise.fromNode((cb) => NginxConfFile.create(nginxConfPath, cb)).then((conf) => {
146152
ctx.ssl.conf = conf;
147153
ctx.ssl.http = conf.nginx.server;
148154
ctx.ssl.http._add('location', '~ /.well-known');

0 commit comments

Comments
 (0)