Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Commit fa041af

Browse files
authored
Merge pull request #107 from netlify/fix-live-starting-before-server-is-running
Make sure we don't start the live tunnel before the dev server is running
2 parents 97dfc0f + db0697b commit fa041af

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

src/commands/dev/index.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ function startDevServer(settings, log, error) {
154154
server.start(function() {
155155
log(`${NETLIFYDEV} Server listening to`, settings.proxyPort);
156156
});
157-
} else {
158-
log(`${NETLIFYDEV} Starting Netlify Dev with ${settings.type}`);
159-
const ps = execa(settings.command, settings.args, {
160-
env: settings.env,
161-
stdio: "inherit"
162-
});
163-
ps.on("close", code => process.exit(code));
164-
ps.on("SIGINT", process.exit);
165-
ps.on("SIGTERM", process.exit);
157+
return;
166158
}
159+
log(`${NETLIFYDEV} Starting Netlify Dev with ${settings.type}`);
160+
const ps = execa(settings.command, settings.args, {
161+
env: settings.env,
162+
stdio: "inherit"
163+
});
164+
ps.on("close", code => process.exit(code));
165+
ps.on("SIGINT", process.exit);
166+
ps.on("SIGTERM", process.exit);
167167
}
168168

169169
class DevCommand extends Command {
@@ -202,19 +202,6 @@ class DevCommand extends Command {
202202
}
203203

204204
let url;
205-
if (flags.live) {
206-
const liveSession = await createTunnel(site.id, accessToken, this.log);
207-
url = liveSession.session_url;
208-
process.env.BASE_URL = url;
209-
210-
await connectTunnel(
211-
liveSession,
212-
accessToken,
213-
settings.port,
214-
this.log,
215-
this.error
216-
);
217-
}
218205

219206
startDevServer(settings, this.log, this.error);
220207

@@ -240,6 +227,22 @@ class DevCommand extends Command {
240227
if (!url) {
241228
url = proxyUrl;
242229
}
230+
231+
if (flags.live) {
232+
await waitPort({ port: settings.proxyPort });
233+
const liveSession = await createTunnel(site.id, accessToken, this.log);
234+
url = liveSession.session_url;
235+
process.env.BASE_URL = url;
236+
237+
await connectTunnel(
238+
liveSession,
239+
accessToken,
240+
settings.port,
241+
this.log,
242+
this.error
243+
);
244+
}
245+
243246
// Todo hoist this telemetry `command` to CLI hook
244247
track("command", {
245248
command: "dev",

0 commit comments

Comments
 (0)