gpt4 book ai didi

coffeescript - grunt.util.spawn 不提供输出

转载 作者:行者123 更新时间:2023-12-02 04:41:11 25 4
gpt4 key购买 nike

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']

最佳答案

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

关于coffeescript - grunt.util.spawn 不提供输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20806839/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com