await Promise.all([
$`sleep 1; echo 1`,
$`sleep 2; echo 2`,
$`sleep 3; echo 3`,
])
The only `exit 1` in the README is an example on how to handle cases where your job fails, so don't really understand what your complaint is. await Promise.all([
$`sleep 1; echo 1`,
$`sleep 2; echo 2`,
$`sleep 3; echo 3`,
])
The only `exit 1` in the README is an example on how to handle cases where your job fails, so don't really understand what your complaint is. sleep 1 && echo 1 &
sleep 2 && echo 2 &
sleep 3 && echo 3 &
wait
and be done with it? Now I don't need to prepend 'await $`...`' in front of every other command.This means that promise.all probably looks something more like
const lastWeek = DateTime.now().minus({ days: 7 }).toISOString()
const pods = JSON.parse(await $`kubectl get pods -o json`)
useValidate(pods, isKubeCtlPodList)
await Promise.all(
pods.filter(pod => !protectedPods.includes(pod.name))
.filter(pod => target.test(pod.name))
.filter(pod => pod.created < lastWeek)
.map(pod => $`kubectl delete pod ${pod.name}`)
)
Id certainly encapsulte my calls, parsing, and validation differently in real code, but you get the gist.In shell I can wrangle jq, date, xargs and get the same result; only this is waay easier to write, gives me validation and usable error messages, and can be altered much more easily than shell.
I write complex bash scripts somewhat often. They can be quicker to write, they are great for one-offs. But if I'm coming back to something non-trivial or if its getting deployed into production I want a language like js or python (or nearly any other language. C++, OCaml, Java all help more than they hinder).
Things like this are why I don't love bash. Whether a script will fail if a step fails is too important to be hidden behind a single character change in a place most people ignore.
(I’ve written massive bash scripts, and now strongly prefer Ruby / python / whatever is available in the system)
But you must understand that I/O in JS is async, it's how the language is build! People who are advanced in async programming find this very comfortable.