gpt4 book ai didi

node.js - npm:如何在每次更改时运行测试和 lint?

转载 作者:搜寻专家 更新时间:2023-11-01 00:31:14 26 4
gpt4 key购买 nike

我正在使用裸npm(没有grunt/gulp)方法来开发我的新 MEAN 项目。
我的配置如下:

文件package.json:

...
"start": "nodemon ./bin/www",
"lint": "jshint **/*.js",
"test": "mocha --recursive",
"dependencies": {
...
},
"devDependencies": {
...
},

开始之前,我运行了一个 npm start 并且 nodemon 开始监视我的项目树的变化,在每次源文件变化后触发重启。
到目前为止一切顺利。

但是,如果我想在每次重新启动时包括 - 比方说 - lint 和/或 test 阶段怎么办?
我没有在 nodemon 中找到任何线索页面也不在 npm一个……

最佳答案

因此您应该在 package.json 中定义开始以首先运行 lint,然后测试实际运行的服务器。您可以在以下帖子中找到示例: http://substack.net/task_automation_with_npm_run

你应该运行'npm run monitor'命令来开始监控,重启应该调用npm run start脚本。

但基本上你想要(基于你的 package.json)

"scripts": {
"start": "npm run lint & npm run test & node ./myfile.js",
"lint": "jshint **/*.js",
"test": "mocha --recursive",
"monitor": "nodemon ./bin/www"
.....

关于node.js - npm:如何在每次更改时运行测试和 lint?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32904262/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com