grunt
grunt copied to clipboard
Stop/warn user when declaring an already existing task or a loop
(this is a proposed feature for discussion, I'll gladly do the PR afterwards)
Sometimes, distracted or new developers declare custom tasks using names that are already used for other tasks, which yields surprising (for them) results. Worse, they sometimes do it in a multi-task, which then causes an infinite loop and baffles them:
grunt.registerTask('uglify', ['build', `copy`, 'uglify']);
grunt.loadNpmTasks('grunt-contrib-uglify');
My proposal would be to have grunt fail with a nice explanation in this case. What do you think?
side note, we have this in the FAQ: http://gruntjs.com/frequently-asked-questions#why-am-i-getting-a-maximum-call-stack-size-exceeded-error
I looked at the code, and would put a check in task.registerTask. that way it's one less risk of error and FAQ entry to maintain :)