1 | 'use strict';
|
2 |
|
3 | var _ = require('lodash');
|
4 |
|
5 | var configureTasks = require('./tasks/configureTasks');
|
6 |
|
7 | var tourism = function (options) {
|
8 | return function (grunt) {
|
9 | options.shell = options.shell || {};
|
10 |
|
11 | configureTasks(options, grunt);
|
12 |
|
13 | grunt.registerTask('analyse', [ 'eslint' ]);
|
14 | grunt.registerTask('analyze', [ 'analyse' ]);
|
15 | grunt.registerTask('test', [ 'mochacli' ]);
|
16 | grunt.registerTask('coverage', [ 'mocha_istanbul:coverage' ]);
|
17 | grunt.registerTask('report', [ 'coverage', 'shell:show-coverage' ]);
|
18 | grunt.registerTask('licenses', [ 'licensechecker' ]);
|
19 | grunt.registerTask('license', [ 'licenses' ]);
|
20 | grunt.registerTask('outdated', [ 'depcheck', 'devUpdate' ]);
|
21 |
|
22 | grunt.registerTask('publish', function (releaseType) {
|
23 | grunt.task.run([ 'checkbranch', 'checkpending', 'gitnobehind', 'default', 'release:' + (releaseType || 'patch') ]);
|
24 | });
|
25 |
|
26 | _.forEach(options.shell, function (command, name) {
|
27 | if (typeof command === 'function') {
|
28 | grunt.registerTask(name, function (arg) {
|
29 | grunt.task.run([ 'shell:' + name + ':' + arg ]);
|
30 | });
|
31 | return;
|
32 | }
|
33 | grunt.registerTask(name, [ 'shell:' + name ]);
|
34 | });
|
35 |
|
36 | if (!options.shell.update) {
|
37 | grunt.registerTask('update', function (pattern) {
|
38 | grunt.task.run([ 'shell:update:' + (pattern || '*'), 'default' ]);
|
39 | });
|
40 | }
|
41 |
|
42 | if (!options.shell.start) {
|
43 | grunt.registerTask('start', [ 'shell:start' ]);
|
44 | }
|
45 | if (options.shell.stop && options.shell.start && !options.shell.restart) {
|
46 | grunt.registerTask('restart', [ 'stop', 'start' ]);
|
47 | }
|
48 | if (options.shell.clean && options.shell.build && !options.shell.rebuild) {
|
49 | grunt.registerTask('rebuild', [ 'clean', 'build' ]);
|
50 | }
|
51 |
|
52 | grunt.registerTask('default', [ 'analyse', 'test', 'outdated', 'license' ]);
|
53 | };
|
54 | };
|
55 |
|
56 | module.exports = tourism;
|