I've created an automator script to run Live server on the selected folder. Although it's not returning any errors (or I can't see) It's not working either.
#!/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
display alert "Stopped"
end if'
Finally once I'm done I would like to terminate it. Which I've tried like this;
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'
But it not working. I don't know much about bash scripting, I just brought things together I've found online.
And this is how I tried with AppleScript
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
activate
end tell
return input
end run
This one works almost as inteded, except it's watching all root folder, so I've tried this;
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
This one says folder cannot be found by live-server.