I have a Node.js file that uses an API to retrieve & download images via an async function that returns a promise.
When I run the Node.js file from MacOS's Terminal app, it waits for my async function to finish downloading the images before exiting. Within Keyboard Maestro however, when I run the Node.js file from the “Execute a Shell Script” action or using the command “do shell script” within the “Execute an AppleScript” action, the script closes almost immediately with no error messages, simply returning an empty string “”.
Here is the command I am running within the “Execute a Shell Script” action or the “Execute an AppleScript” action (using the command “do shell script "…"”)
Within Keyboard Maestro, how can I make the shell script wait for the async function to finish like it does when run from the Terminal app?
Note: if I include the $PATH variable from the Terminal app into Keyboard Maestro, the same issue occurs. So I'm not clear on what's causing the behaviour difference.