Skip to content

Commit e5d2c29

Browse files
run wait for install (cloudflare#28)
Co-authored-by: Avery Harnish <averyharnish@gmail.com> Co-authored-by: avery <avery@apollographql.com>
1 parent b1b82e5 commit e5d2c29

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

packages/binary-install/index.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,28 @@ class Binary {
9797
}
9898

9999
run(fetchOptions) {
100-
if (!this.exists()) {
101-
this.install(fetchOptions, true);
102-
}
100+
const promise = !this.exists()
101+
? this.install(fetchOptions, true)
102+
: Promise.resolve();
103103

104-
const [, , ...args] = process.argv;
104+
promise
105+
.then(() => {
106+
const [, , ...args] = process.argv;
105107

106-
const options = { cwd: process.cwd(), stdio: "inherit" };
108+
const options = { cwd: process.cwd(), stdio: "inherit" };
107109

108-
const result = spawnSync(this.binaryPath, args, options);
110+
const result = spawnSync(this.binaryPath, args, options);
109111

110-
if (result.error) {
111-
error(result.error);
112-
}
112+
if (result.error) {
113+
error(result.error);
114+
}
113115

114-
process.exit(result.status);
116+
process.exit(result.status);
117+
})
118+
.catch(e => {
119+
error(e.message);
120+
process.exit(1);
121+
});
115122
}
116123
}
117124

0 commit comments

Comments
 (0)