I am trying to start a live-server on demand in any folder temporarily with automator, and kill it when I'm done.
Live server is a node package. I've installed globally.
In terminal, if I go to any folder and run;
live-server --port=XXXX
starts the live server for that folder. But I couldn't manage to run with automator.
I've tried various things;
Automator > Quickaction
Shell Script This one doesn't return any error, but nothing seems to executed.
#!/bin/bash
~/.zprofile live-server --port=5010 --open=$1
osascript -e 'set alertResult to display alert "Live Server running on \n'$1'\n PID: '$$'" buttons {"STOP"} as warning
if button returned of result = "STOP" then
do shell script "kill -9 '$$'
end if'
AppleScript, If I run it with out watch
parameter it works, but it's watching ~/
folder, if I add watch=
doesn't work at all (folder not found)
on run {input, parameters}
set folderPath to (the POSIX path of input)
tell application "Terminal"
do script ("live-server --port=5010 --open=" & folderPath as string) & " --watch=" & folderPath as string
activate
end tell
return input
end run
Shell Script So I've decided to make a bash script. Automator content;
source ~/.zprofile
~/.nvm/versions/node/v16.19.0/bin/launcher.sh $1
Here is the bash script content. This is working but this time live-server returns 404 (I believe it's about permissions this time)
#!/bin/zsh
source ~/.zprofile
cd ~/.nvm/versions/node/v16.19.0/lib/node_modules/live-server
~/.nvm/versions/node/v16.19.0/bin/node live-server.js --port=5010 --open=${1}/
Can someone explain what is going wrong?