2016-05-15 63 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