I have almost no idea about shell scripts or commands in linux
I have a project named projectx
projectX
happens to be in users/hardik/desktop/projectx
I have created a shell script start.sh
. This is the content of shell script
echo "Starting typescript build in new terminal.."
osascript -e 'tell application "Terminal" to do script "npm run build"'
sleep 3
echo "Starting firebase functions...."
osascript -e 'tell application "Terminal" to do script "firebase emulators:start --only functions"'
echo "Process compelete.. Check if there were two terminals window open"
now this works but say here
osascript -e 'tell application "Terminal" to do script "npm run build"'
it runs that in the root and hence gives the following error
ENOENT: no such file or directory, open /Users/hardik/package.json
How can I make it execute in the path which is relative to start.sh
Update: I tried these but it didn't work
cd "$(dirname $(readlink -f "$0"))"
echo "Starting typescript build in new terminal.."
osascript -e 'tell application "Terminal" to do script "npm run watch:scss"'
osascript -e 'tell application "Terminal" to do script "npm run watch"'
echo "Process compelete.. Check if there were two terminals window open"
This is what it logs for the above
readlink: illegal option -- f
usage: readlink [-n] [file ...]
usage: dirname path
Starting typescript build in new terminal..
tab 1 of window id 1579
tab 1 of window id 1580
also the below snippet doesn't work either
cd -P -- "${0%/*}" || exit
echo "Starting typescript build in new terminal.."
osascript -e 'tell application "Terminal" to do script "npm run watch:scss"'
osascript -e 'tell application "Terminal" to do script "npm run watch"'
echo "Process compelete.. Check if there were two terminals window open"
Same error
npm watch
. I want one command to start everything. Since both of them are watch, they might also throw error if something goes wrong. for that, I don't want things to happen in the same terminal and I also don't want to run two npm commands whenever I start a project. – iRohitBhatia Jun 30 '20 at 21:34