-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
79 lines (66 loc) · 2.31 KB
/
Gruntfile.js
File metadata and controls
79 lines (66 loc) · 2.31 KB
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
'use strict';
var semver = require('semver');
module.exports = function (grunt) {
require('time-grunt')(grunt);
var oldNode = /^v[045]\./.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({
eslint: {
all: {
src: [
'*.js',
'bin/grunth',
'lib/*.js',
],
},
},
});
// 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('asserts', function () {
try {
/* eslint-disable no-eval */
eval('function* f() {yield 2;} var g = f(); g.next();');
/* eslint-ensable no-eval */
} catch (e) {
throw new Error('Generators not recognized!');
}
grunt.log.writeln('Generators recognized.');
try {
/* eslint-disable no-eval */
eval('function f() {"use strict"; const x = 2; let y = 3; return [x, y];} f();');
/* eslint-ensable no-eval */
} catch (e) {
throw new Error('Block scoping (const/let) not recognized!');
}
grunt.log.writeln('Block scoping (const/let) recognized.');
if (semver.satisfies(process.version, '>=1.0.0')) {
if (process.execArgv.indexOf('--harmony') === -1) {
throw new Error('The --harmony flag was not passed!');
}
grunt.log.writeln('The --harmony flag was passed.');
}
});
grunt.registerTask('lint', [
runIfNewNode('eslint'),
]);
grunt.registerTask('test', [
'lint',
'asserts',
]);
grunt.registerTask('default', ['test']);
};