2016-05-15 90 views
0

有沒有辦法打開命令提示符並在我的PC啓動時從我的項目目錄運行grunt watch?只是試圖自動化自動化,花了好半個小時用沒有運氣的Google搜索。從啓動窗口運行grunt watch 10

回答

0

有一個模塊將節點腳本安裝爲windows服務,它被稱爲node-windows(npm,github,documentation)。我以前用過,像魅力一樣工作。

var Service = require('node-windows').Service;  
// Create a new service object 
var svc = new Service({ 
name:'Hello World', 
description: 'The nodejs.org example web server.', 
script: 'C:\\path\\to\\helloworld.js' 
}); 

// Listen for the "install" event, which indicates the 
// process is available as a service. 
svc.on('install',function(){ 
svc.start(); 
}); 

svc.install(); 

安裝它:

npm install -g qckwinsvc 

安裝服務:

> qckwinsvc 
prompt: Service name: [name for your service] 
prompt: Service description: [description for it] 
prompt: Node script path: [path of your node script] 
Service installed 

卸載您的服務:

> qckwinsvc --uninstall 
prompt: Service name: [name of your service] 
prompt: Node script path: [path of your node script] 
Service stopped 
Service uninstalled