diff --git a/cli/mod.ts b/cli/mod.ts index bc9f0fcaf..5af5b539a 100644 --- a/cli/mod.ts +++ b/cli/mod.ts @@ -20,6 +20,7 @@ export async function main() { } else { await commandLine(Deno.args) } + Deno.exit(0) } await main() diff --git a/cli/src/commands/download.ts b/cli/src/commands/download.ts index b3b28d3d3..e3cedc311 100644 --- a/cli/src/commands/download.ts +++ b/cli/src/commands/download.ts @@ -57,11 +57,14 @@ export async function downloadAction( // Close after all tasks are queued worker.postMessage({ command: "done" }) - worker.addEventListener("message", (event) => { - if (event.data.command === "closed") { - console.log( - "Download complete. To download all data files, use `datalad get` or `git-annex get`.", - ) + await new Promise((resolve) => { + worker.onmessage = (event) => { + if (event.data.command === "closed") { + console.log( + "Download complete. To download all data files, use `datalad get` or `git-annex get`.", + ) + resolve() + } } }) } diff --git a/cli/src/commands/upload.ts b/cli/src/commands/upload.ts index 9b93a6136..3ea8c83db 100644 --- a/cli/src/commands/upload.ts +++ b/cli/src/commands/upload.ts @@ -153,6 +153,14 @@ export async function uploadAction( // Close after all tasks are queued worker.postMessage({ command: "done" }) + + await new Promise((resolve) => { + worker.onmessage = (event) => { + if (event.data.command === "closed") { + resolve() + } + } + }) } /**