本文介绍了咕噜任务完成后运行命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想运行命令,但I want to run a command but after a task finishes in grunt.uglify: { compile: { options: {...}, files: {...} } ?onFinish?: { cmd: 'echo done!', // or even just a console.log run: function(){ console.log('done!'); } }}, shell,甚至能够 console.log 。这可能吗?Either run a command in shell, or even just be able to console.log. Is this possible?推荐答案 Grunt在回调之前和之后都不支持,但是下一个版本可以实现在相同的情况下运行的事件如 issue#542 中所述。Grunt does not support before and after callbacks, but next version could implement events that would work in the same way, as discussed in issue #542.现在,您应该执行任务组合方式,即为操作前后的操作创建任务,并用新名称对其进行分组:For now, you should go the task composition way, this is, create tasks for those before and after actions, and group them with a new name:grunt.registerTask('newuglify', ['before:uglify', 'uglify', 'after:uglify']);然后记得运行 newuglify 而不是 uglify 。另一个选项不是对它们进行分组,而是记住分别将前后任务添加到包含 uglify :Another option is not to group them but remember to add the before and after tasks individually to a queue containing uglify:grunt.registerTask('default', ['randomtask1', 'before:uglify', 'uglify', 'after:uglify', 'randomtask2']);运行命令可以使用像 grunt-exec 或 grunt-shell 。For running commands you can use plugins like grunt-exec or grunt-shell.如果您只想打印某些内容,请尝试 grunt.log 。If you only want to print something, try grunt.log. 这篇关于咕噜任务完成后运行命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-17 18:18