UNPKG

1.76 kBJavaScriptView Raw
1'use strict';
2
3var _ = require('lodash');
4
5var configureTasks = require('./tasks/configureTasks');
6
7var 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('outdated', [ 'depcheck', 'devUpdate' ]);
19
20 grunt.registerTask('publish', function (releaseType) {
21 grunt.task.run([ 'checkbranch', 'checkpending', 'gitnobehind', 'default', 'release:' + (releaseType || 'patch') ]);
22 });
23
24 _.forEach(options.shell, function (command, name) {
25 if (typeof command === 'function') {
26 grunt.registerTask(name, function (arg) {
27 grunt.task.run([ 'shell:' + name + ':' + arg ]);
28 });
29 return;
30 }
31 grunt.registerTask(name, [ 'shell:' + name ]);
32 });
33
34 if (!options.shell.update) {
35 grunt.registerTask('update', function (pattern) {
36 grunt.task.run([ 'shell:update:' + (pattern || '*'), 'default' ]);
37 });
38 }
39
40 if (!options.shell.start) {
41 grunt.registerTask('start', [ 'shell:start' ]);
42 }
43 if (options.shell.stop && options.shell.start && !options.shell.restart) {
44 grunt.registerTask('restart', [ 'stop', 'start' ]);
45 }
46 if (options.shell.clean && options.shell.build && !options.shell.rebuild) {
47 grunt.registerTask('rebuild', [ 'clean', 'build' ]);
48 }
49
50 grunt.registerTask('default', [ 'analyse', 'test', 'outdated' ]);
51 };
52};
53
54module.exports = tourism;