-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.js
113 lines (99 loc) · 2.82 KB
/
Gruntfile.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
112
113
/**
* grunt-defs
* https://github.com/EE/grunt-defs
*
* Author Michał Gołębiowski-Owczarek <[email protected]>
* Copyright (c) 2013 Laboratorium EE
* Licensed under the MIT license.
*/
'use strict';
module.exports = function (grunt) {
require('time-grunt')(grunt);
var oldNode = /^v0\./.test(process.version);
// Support: Node.js <4
// Skip running tasks that dropped support for Node.js 0.12
// in thise Node version.
var runIfNewNode = function (task) {
return oldNode ? 'print_old_node_message:' + task : task;
};
grunt.initConfig({
clean: {
test: {
src: ['test/tmp'],
},
},
eslint: {
all: {
src: [
'Gruntfile.js',
'tasks',
'test',
],
},
},
// Copy files to be processed by the defs task to the temporary directory.
copy: {
defs: {
files: {
'test/tmp/src3.js': 'test/fixtures/src3.js',
},
},
},
// Configuration to be run (and then tested).
defs: {
options: {
defsOptions: {
disallowUnknownReferences: false,
},
},
simple: {
files: {
'test/tmp/src1.js': 'test/fixtures/src1.js',
},
},
loopClosures: {
options: {
defsOptions: {
loopClosures: 'iife',
},
},
files: {
'test/tmp/src2.js': 'test/fixtures/src2.js',
},
},
},
// Unit tests.
mochaTest: {
all: {
options: {
reporter: 'spec',
},
src: ['test/spec.js'],
},
},
});
// Actually load this plugin's task(s).
grunt.loadTasks('tasks');
// Load grunt tasks from NPM packages
// Support: Node.js <4
// Don't load the eslint task in old Node.js, it won't parse.
require('load-grunt-tasks')(grunt, {
pattern: oldNode ? ['grunt-*', '!grunt-eslint'] : ['grunt-*'],
});
// Supports: Node.js <4
grunt.registerTask('print_old_node_message', function () {
var task = [].slice.call(arguments).join(':');
grunt.log.writeln('Old Node.js detected, running the task "' + task + '" skipped...');
});
grunt.registerTask('lint', [
runIfNewNode('eslint'),
]);
// By default, lint and run all tests.
grunt.registerTask('default', [
'clean',
'lint',
'copy',
'defs',
'mochaTest',
]);
};