你如何让默认的grunt.js不会在警告中崩溃? [英] How do you make grunt.js not crash on warnings by default?

查看:110
本文介绍了你如何让默认的grunt.js不会在警告中崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Grunt来编译CoffeeScript和Stylus以及一个watch任务。



不幸的是,如果Grunt遇到语法错误,任何它正在编译的文件,它会抛出警告并退出由于警告而中止。我可以通过传递 --force 来阻止它。有什么方法可以不中止默认行为(或者控制哪些任务的警告足够重要,以便退出Grunt?)

解决方案

注册你自己的任务,它将运行你想要的任务,然后你必须通过 force 选项:

  grunt.registerTask('myTask','执行我的任务',function(){
var tasks = ['task1',...,'watch'];

//对上一行声明的所有任务使用force选项
grunt.option('force',true);
grunt.task.run(tasks);
});


I'm using Grunt to compile CoffeeScript and Stylus with a watch task. I also have my editor (SublimeText) set to save files every time I page away from them (I hate losing work).

Unfortunately, if Grunt hits a syntax error in any of the files it's compiling, it throws a warning and quits with Aborted due to warnings. I can stop it doing this by passing --force. Is there any way to make not aborting the default behavior (or control which tasks' warnings are important enough to quit Grunt?

解决方案

Register your own task, which will run the tasks you want. Then you have to pass the force option:

grunt.registerTask('myTask', 'runs my tasks', function () {
    var tasks = ['task1', ..., 'watch'];

    // Use the force option for all tasks declared in the previous line
    grunt.option('force', true);
    grunt.task.run(tasks);
});

这篇关于你如何让默认的grunt.js不会在警告中崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆