2015-10-02 48 views
1

我正在使用裸機npm(沒有grunt/gulp)開發我的新MEAN項目。
我的配置是這樣的:npm:如何在每次更改時運行測試和皮棉?

文件的package.json:

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

在開始之前,我運行一個npm startnodemon開始監視我的更改項目樹,每個源之後觸發重啓文件更改。
到目前爲止這麼好。

但是如果我想在每次重新啓動時包括 - 說 - lint和/或test階段怎麼辦?
我沒有找到任何線索,也沒有在nodemon頁面也不在npm一個...

回答

3

所以,你應該在你的package.json首先運行皮棉開始的定義,比考比實際運行服務器。 您可以在下面的帖子爲例: http://substack.net/task_automation_with_npm_run

您應該運行「故宮運行監控器」命令,啓動監控和重啓應該叫故宮運行啓動腳本。

但基本上你想有(根據您的package.json)

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

什麼是'/ myfile.js'? – MarcoS

+0

你的app.js文件,你開始你的應用程序。 – sagie

+0

這是一個express.js應用程序,所以我運行'。/ bin/www' ... – MarcoS

相關問題