aboutsummaryrefslogtreecommitdiffgithub
diff options
context:
space:
mode:
authorAustin Adams <git@austinjadams.com>2019-01-25 21:16:28 -0600
committerAustin Adams <git@austinjadams.com>2019-01-25 21:16:28 -0600
commitbd36031b3e1d023022bcf55fa20b71d0df604ee6 (patch)
tree4350f27ef470c0324e4e93465b0e3153dd3b5389
parent7f2a57c663d40cfb81797897ab8d9c6aff1a3103 (diff)
downloadnovice-bd36031b3e1d023022bcf55fa20b71d0df604ee6.tar.gz
novice-bd36031b3e1d023022bcf55fa20b71d0df604ee6.tar.xz
cli: Properly wait for stdin to be readable
-rw-r--r--novice/cli.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/novice/cli.ts b/novice/cli.ts
index 4325fef..aefbb04 100644
--- a/novice/cli.ts
+++ b/novice/cli.ts
@@ -116,10 +116,12 @@ async function sim(configName: string, path: string, stdin: Readable,
try {
const cfg = getSimulatorConfig(configName);
const fp = fs.createReadStream(path);
- await new Promise((resolve, reject) => {
- fp.on('readable', resolve);
- fp.on('error', reject);
- });
+ await Promise.all([fp, stdin].map(
+ f => new Promise((resolve, reject) => {
+ f.on('readable', resolve);
+ f.on('error', reject);
+ })
+ ));
const io = new StreamIO(stdin, stdout);
const simulator = new Simulator(cfg.isa, io);
cfg.loader.load(cfg.isa, fp, simulator);