Run specific task(s) with force option
Open
Type: Enhancement
- Dominant language
- JavaScript
- Stars
- 12.2k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
I see that several plug-ins have added a force option, for example:
https://github.com/gruntjs/grunt-contrib-jshint#force
https://github.com/gruntjs/grunt-contrib-clean#force
But it would be useful to have a general-purpose way of doing this at the grunt level. Here's what I'm currently doing for a workaround:
grunt.registerTask('usetheforce_on',
'force the force option on if needed',
function() {
if ( !grunt.option( 'force' ) ) {
grunt.config.set('usetheforce_set', true);
grunt.option( 'force', true );
}
});
grunt.registerTask('usetheforce_restore',
'turn force option off if we have previously set it',
function() {
if ( grunt.config.get('usetheforce_set') ) {
grunt.option( 'force', false );
}
});
grunt.registerTask( 'myspecialsequence', [
'usetheforce_on',
'task_that_might_fail_and_we_do_not_care',
'another_task',
'usetheforce_restore',
'qunit',
'task_that_should_not_run_after_failed_unit_tests'
] );
Is there a better workaround? If not, would you consider adding a feature for this?
Contributor guide
Assessment
This issue has not been assessed yet.