npm 开始执行许多预启动脚本 [英] npm starts to execute many prestart scripts
本文介绍了npm 开始执行许多预启动脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,我有一个使用 npm 的项目.我需要它来编译几个 .coffee 脚本.
Ok, I have a project where I use npm. I need it to compile several .coffee scripts.
我需要执行多个预启动脚本,例如:
I need to execute multiple prestart scripts, like:
"scripts": {
"prestart": "coffee -c ./file1.coffee",
"prestart": "coffee -c ./file2.coffee",
"prestart": "coffee -c ./file3.coffee",
"prestart": "coffee -c ./file4.coffee",
"start": "node ./file1.js"
},
但它似乎只执行最后一个,并且它不允许我在一个上附加许多脚本,例如:
But it only seems to execute the last one, and it doesn't let me append many scripts on one like:
"prestart": "coffee -c ./file1.coffee; coffee -c./file2.coffee"
我能做什么?
推荐答案
将它们包装在父脚本中
"scripts": {
"prestart": "sh ./make-coffee.sh",
"start": "node ./file1.js"
},
//make-coffee.sh
#!/bin/bash
coffee -c ./file1.coffee
coffee -c ./file2.coffee
coffee -c ./file3.coffee
coffee -c ./file4.coffee
或其他(仅限于 Unix)的解决方案是运行多个命令.我不知道如果早期命令失败会发生什么.
or another (unix-only) solution is to run multiple commands. I don't know what happens if the early commands fail.
"scripts": {
"prestart": "coffee -c ./file1.coffee; coffee -c ./file2.coffee; coffee -c ./file3.coffee; coffee -c ./file4.coffee",
"start": "node ./file1.js"
},
这篇关于npm 开始执行许多预启动脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文