Grunt: How to compose two multitasking as another multitasking plugin?

I have several npm modules for which I would like to use the general linting configuration. I have jshint and clinter linter working on the same project through Grunt. But copying / pasting a .jshintignore and .jshintrc file for each project will be cumbersome, especially when something needs to be changed. Therefore, ideally, I would like to have one grunt task that encapsulates the general configuration and can be loaded via

grunt.loadNpmTasks('grunt-mysuperlint'); 

Where grunt-my-common-lint-tasks are the really specific default configurations for jshint and linter.

But I do not see the possibility of creating two existing grunt plugins in one, where the only real composition is the merging of options and goals.

Is it possible?

I should do something like:

 grunt.registerMultiTask('mysuperlint', function() { // Manual options merging? var opts = this.options({ jshint: { src: 'scripts/**/*.js', options: { ... } }, closureLinter: { src: 'scripts/**/*.js', options: { ... } } }); grunt.config.set('jshint.dev', opts.jshint); grunt.config.set('closureLinter.dev', opts.closureLinter); grunt.task.run('jshint:dev'); grunt.task.run('closureLinter:dev'); }); 

Any help or pointers would be really appreciated.

+6
source share
1 answer

Although this does not directly answer your question, I could offer a simple trick for your original problem: You can have one global .jshintignore file and a soft link to it from each project. This is a kind of hack, but it is easier.

0
source

Source: https://habr.com/ru/post/956022/


All Articles