Skip to content

Commit

Permalink
watch: Making writeOutput calls synchronous (#19)
Browse files Browse the repository at this point in the history
* Making writeOutput calls synchronous.

* fixup
  • Loading branch information
pkedy authored Jan 20, 2023
1 parent 1951674 commit a313aba
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/commands/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,14 @@ async function watch(configurations: string[]) {

let confs = specMap[p];
if (confs) {
for (const conf of confs) {
try {
const outputs = await processConfiguration(conf);
outputs.forEach((output) => writeOutput(output));
} catch (e) {
log.error(e);
}
}
await processAndWrite(confs);
}

confs = configMap[p];
if (confs) {
watcher.close();
await reloadConfigurations();
for (const conf of confs) {
try {
const outputs = await processConfiguration(conf);
outputs.forEach((output) => writeOutput(output));
} catch (e) {
log.error(e);
}
}
await processAndWrite(confs);
return;
}
}
Expand Down Expand Up @@ -138,3 +124,16 @@ async function watch(configurations: string[]) {
});
});
}

async function processAndWrite(confs: Configuration[]) {
for (const conf of confs) {
try {
const outputs = await processConfiguration(conf);
for (const output of outputs) {
await writeOutput(output);
}
} catch (e) {
log.error(e);
}
}
}

0 comments on commit a313aba

Please sign in to comment.