使用osascript脚本打开终端并运行npm命令

时间:2020-06-25 16:26:48

标签: macos unix npm

我对max unix命令的了解不多。

我想做的是打开两个不同的终端,并在每个终端中运行npm。

echo "Starting typescript build in new terminal.."

osascript -e  'npm run build'

sleep 3

echo "Starting firebase functions...."

osascript -e 'firebase emulators:start --only functions'

echo "Process compelete.. Check if there were two terminals window open"

这是我写的,这是我在终端中得到的

Starting typescript build in new terminal..
8:13: syntax error: Expected “given”, “with”, “without”, other parameter name, etc. but found identifier. (-2741)
Starting firebase functions....
0:18: syntax error: A identifier can’t go after this identifier. (-2740)
Process compelete.. Check if there were two terminals window open

somone可以帮助我更正我的shell脚本

1 个答案:

答案 0 :(得分:1)

赞:

osascript -e 'tell application "Terminal" to do script "cd && npm run build"' &
osascript -e 'tell application "Terminal" to do script "cd && firebase emulators:start --only functions"' &