use*_*435 2 coffeescript gruntjs
Grunt.util.spawn没有调用done函数.这是代码.当命令从命令提示符执行时它失败并抛出一条错误消息,该消息未在gruntjs中捕获.发生了什么
module.exports = (grunt)->
grunt.initConfig
concurrent:
dev: ['watch']
slim:
dev:
expand: true
src: 'views'
dest: 'views/'
watch:
slim:
files: 'views/**.slim'
tasks:['slim']
grunt.registerMultiTask 'slim', 'Server Slim Compiler', ->
console.log 'In the slim'
options = {}
options.cmd = 'dirld'
options.grunt = true
console.log options
grunt.util.spawn options, (err,res,cod)->
console.log 'in the spawn'
if err
grunt.log.error err
else
grunt.log.oklns 'success'
grunt.log.writeln res
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-concurrent'
grunt.registerTask 'default', ['concurrent:dev']
Run Code Online (Sandbox Code Playgroud)
grunt.util.spawn是异步的,所以你需要让你的slim任务异步.请参阅:http://gruntjs.com/frequently-asked-questions#why-doesn-t-my-asynchronous-task-complete
grunt.registerMultiTask 'slim', 'Server Slim Compiler', ->
done = @async()
grunt.util.spawn options, (err,res,cod) ->
done() # Im done, continue onto the next task
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1663 次 |
| 最近记录: |