Reputation: 7933
I would like to have a common task in GruntJS, which wouldn't be run for second time if already run by different task in the same session.
For example, I have tasks:
grunt.registerTask("make_win", ["prepare_dist", "copy_win", "compress_win"]);
grunt.registerTask("make_linux", ["prepare_dist", "copy_linux", "compress_linux"]);
grunt.registerTask("make", ["make_win", "make_linux"]);
How it works right now:
What I want to achieve:
Upvotes: 0
Views: 88
Reputation: 43526
Create a callback as a task, in the task check if run
true or not:
grunt.registerTask('foo', 'A sample task that runs once.', function() {
if (!run) {
grunt.task.run('bar');
run = true;
}
});
Upvotes: 3
Reputation: 13273
Hmm... I see what you want, and I think it's a neat idea, but I don't think there is anything in Grunt set up to do this. Unfortunately, I think the only way to do this is to split out the tasks a bit more:
grunt.registerTask("make_win_specific", ["copy_win", "compress_win"]);
grunt.registerTask("make_linux_specific", ["copy_linux", "compress_linux"]);
grunt.registerTask("make_win", ["prepare_dist", "make_win_specific"]);
grunt.registerTask("make_linux", ["prepare_dist", "make_linux_specific"]);
grunt.registerTask("make", ["prepare_dist", "make_win_specific", "make_linux_specific"]);
Upvotes: 0