forked from bocoup/chatter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.babel.js
111 lines (100 loc) · 2.42 KB
/
Gruntfile.babel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import 'source-map-support/register';
import {grunt} from './Gruntfile';
const negate = p => `!${p}`;
const exclude = a => Array.isArray(a) ? a.map(negate) : negate(a);
const SOURCE_DIR = 'src';
const SOURCE_GLOB = '**/*.js';
const TEST_GLOB = '**/*.test.js';
const BUILD_DIR = 'dist';
const BUILD_FILES = ['*.js', 'tools/**/*.js'];
const LEGACY_BUILD_FILES = ['Gruntfile.js'];
const LINT_FILES = ['.eslintrc*', 'eslint/**/*'];
const TEST_FILES = [`${SOURCE_DIR}/${TEST_GLOB}`];
const SRC_FILES = [`${SOURCE_DIR}/${SOURCE_GLOB}`, ...exclude(TEST_FILES)];
const EXAMPLE_FILES = ['examples/**/*.js'];
const babel = {
build: {
expand: true,
cwd: SOURCE_DIR,
src: [SOURCE_GLOB, exclude(TEST_GLOB)],
dest: BUILD_DIR,
},
};
const clean = {
build: BUILD_DIR,
};
const watch = {
src: {
files: SRC_FILES,
tasks: ['eslint:src', 'mochaTest', 'build'],
},
examples: {
files: EXAMPLE_FILES,
tasks: ['eslint:examples'],
},
test: {
files: TEST_FILES,
tasks: ['eslint:test', 'mochaTest'],
},
build: {
options: {reload: true},
files: [...BUILD_FILES, ...LEGACY_BUILD_FILES],
tasks: ['eslint:build', 'eslint:legacy_build', 'mochaTest', 'build'],
},
lint: {
options: {reload: true},
files: LINT_FILES,
tasks: ['eslint'],
},
};
const eslint = {
src: {
options: {configFile: '.eslintrc-es2015.yaml'},
src: SRC_FILES,
},
examples: {
options: {configFile: '.eslintrc-examples.yaml'},
src: EXAMPLE_FILES,
},
test: {
options: {configFile: '.eslintrc-mocha.yaml'},
src: TEST_FILES,
},
legacy_build: {
options: {configFile: '.eslintrc-es5.yaml'},
src: LEGACY_BUILD_FILES,
},
build: {
options: {configFile: '.eslintrc-es2015.yaml'},
src: [...BUILD_FILES, ...exclude(LEGACY_BUILD_FILES)],
},
};
const mochaTest = {
test: {
options: {
reporter: 'spec',
quiet: false,
clearRequireCache: true,
require: [
'babel-register',
'tools/test-globals',
],
},
src: TEST_FILES,
},
};
grunt.initConfig({
clean,
babel,
eslint,
mochaTest,
watch,
});
grunt.registerTask('test', ['eslint', 'mochaTest']);
grunt.registerTask('build', ['clean', 'babel']);
grunt.registerTask('default', ['watch']);
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-mocha-test');