Skip to content

Commit

Permalink
[build] Wait for Flow
Browse files Browse the repository at this point in the history
  • Loading branch information
charlag committed Jan 27, 2021
1 parent 22a861a commit 8a7ef02
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions make.js
Expand Up @@ -24,7 +24,10 @@ options
})
.parse(process.argv)

spawn(flow, ["--quiet"], {stdio: "inherit"})
const flowPromise = new Promise((resolve, reject) => {
// It's better to set listener right away
spawn(flow, ["--quiet"], {stdio: "inherit"}).on("exit", resolve).on("error", reject)
})

const SOCKET_PATH = "/tmp/buildServer"

Expand All @@ -38,17 +41,19 @@ function runBuild() {
socketPath: SOCKET_PATH,
buildOpts: opts,
})
.then(() => {
.then(async () => {
console.log("Build finished")
if (opts.desktop) {
// we don't want to quit here because we want to keep piping output to our stdout.
spawn("./start-desktop.sh", {stdio: "inherit"})
} else if (!opts.watch) {
await flowPromise
process.exit(0)
}
})
.catch(e => {
.catch(async e => {
console.error(e)
await flowPromise
process.exit(1)
})
}
Expand Down

0 comments on commit 8a7ef02

Please sign in to comment.