如何将一个npm脚本转换成一个咕噜的任务?
我有我的nodeJS下面的脚本。
"scripts": { "start": "grunt", "test": "node --debug --harmony node_modules/grunt-cli/bin/grunt test" }
我正在运行节点v0.11.13,所以我需要设置 – 和谐标志。 在咕噜的testingconfiguration正确,如果我用npmtesting启动它们,但我宁愿将它全部在一个grunt文件。 有没有办法configurationgrunt来启动服务器,并运行testing?
你可以创build一个别名任务,用这些节点标志来产生咕噜声,就像这样:
grunt.registerTask('debug', function() { var done = this.async(); // Specify tasks to run spawned var tasks = Array.prototype.slice.call(arguments, 0); grunt.util.spawn({ // Use the existing node path cmd: process.execPath, // Add the flags and use process.argv[1] to get path to grunt bin args: ['--debug', '--harmony', process.argv[1]].concat(tasks), // Print everything this process is doing to the parent stdio opts: { stdio: 'inherit' } }, done); });
然后你可以启动服务器并运行testing: grunt default debug:test
或者真的是任何组合:
-
grunt server test
(运行时没有节点标志) -
grunt debug:server:test
(与节点标志一起运行)。
- 如何在运行摩卡testing之前等待一个咕噜的任务完成
- sails.js使用不同的布局与不同的js库
- 运行跨多个grunt.js文件configuration的任务
- 在Windows上Jenkins + Grunt =常数EBUSY和ENOENT错误
- Gruntjs:致命错误:getaddrinfo ENOTFOUND
- 使用grunt-contrib-connect和grunt-connect-rewrite删除文件扩展名
- 如何在打开Visual Studio项目/解决scheme时自动启动grunt watch?
- 致命的错误:产卵cmd ENOENT – 咕serve服务
- CSSLint:如何configuration任务只是打印错误不警告