admin管理员组文章数量:1345307
I'm trying to create a custom task in grunt that automatically invokes its "prerequisites". I'm not sure on how to do that. The Grunt.js docs show this example:
grunt.registerTask('foo', 'My "foo" task.', function() {
// Enqueue "bar" and "baz" tasks, to run after "foo" finishes, in-order.
grunt.task.run('bar', 'baz');
... // Other stuff here
});
I don't want to "enqueue bar
and baz
after foo
", I want to execute them right there, where the grunt.task.run
line is, so they get executed before my "Other stuff".
How do I do that?
I'm trying to create a custom task in grunt that automatically invokes its "prerequisites". I'm not sure on how to do that. The Grunt.js docs show this example:
grunt.registerTask('foo', 'My "foo" task.', function() {
// Enqueue "bar" and "baz" tasks, to run after "foo" finishes, in-order.
grunt.task.run('bar', 'baz');
... // Other stuff here
});
I don't want to "enqueue bar
and baz
after foo
", I want to execute them right there, where the grunt.task.run
line is, so they get executed before my "Other stuff".
How do I do that?
Share Improve this question edited Feb 26, 2013 at 22:30 kikito asked Feb 26, 2013 at 22:23 kikitokikito 52.8k33 gold badges154 silver badges197 bronze badges1 Answer
Reset to default 13I think your only way to do it currently would be via creating and additional task
grunt.registerTask('fooTask', 'My "foo" task.', function() {
grunt.task.requires('bar'); // make sure bar was run and did not fail
grunt.task.requires('baz'); // make sure bar was run and did not fail
... // Other stuff here
});
grunt.registerTask('foo', 'My "foo" sequence.', ['bar', 'baz', 'fooTask']);
本文标签: javascriptHow do I invoke other tasks from my custom task *before* my task code runsStack Overflow
版权声明:本文标题:javascript - How do I invoke other tasks from my custom task *before* my task code runs? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743812009a2543242.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论