2017-09-06 93 views
1

我在package.jason有这样的命令:如何让终端命令等待另一个完成?

"chrome": "node --max_old_space_size=10000 build/dev-server.js --arg testus | node --harmony test/e2e/puppeteer/index.js", 

我想用我的自动化测试工具之前建立我的应用程序。

但现在这两个命令同时启动。

如何做第二个等待第一个完成?

+0

的可能的复制[运行NPM脚本顺序(HTTPS:/ /stackoverflow.com/questions/39172536/running-npm-scripts-sequentially) –

回答

1

要运行序列东西在Linux命令行使用&&

"chrome": "node --max_old_space_size=10000 build/dev-server.js --arg testus && node --harmony test/e2e/puppeteer/index.js", 
+0

哦,它几乎奏效。但是现在服务器正在监听端口8080,并且它在'&&'后面没有运行命令就卡在那里了...... – alex

+0

另一种方法是使用'&'将服务器置于后台,然后在' ' 'first_command&; second_command' ';'与序列的&&相同 –

1

怎么样正确的bash脚本,如:

node --max_old_space_size=10000 build/dev-server.js --arg testus 
while [ ! $(http://example.org 2>/dev/null | head -n 1 | cut -d$' ' -f2) -eq 200 ]; do 
    echo "Waiting for server to start!" 
    sleep 2 
done 
echo "Server started !!!! " 
node --harmony test/e2e/puppeteer/index.js"