-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathGruntfile.js
102 lines (86 loc) · 2.27 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
'use strict';
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
all: ['src/*.js', 'tests/*.tests.js']
},
version: {
src: 'Pilot.js'
},
qunit: {
all: ['tests/index.html'],
options: {
'--web-security': 'no',
coverage: {
src: ['<%=jshint.all%>'],
instrumentedFiles: '/tmp/',
htmlReport: 'report/coverage',
coberturaReport: 'report/',
linesThresholdPct: 80,
functionsThresholdPct: 80,
branchesThresholdPct: 70,
statementsThresholdPct: 80
}
}
},
uglify: {
options: {
banner: '/*! Pilot <%= pkg.version %> - <%= pkg.license %> | <%= pkg.repository.url %> */\n'
},
dist: {
files: {
'Pilot.min.js': ['Pilot.js']
}
}
},
requirejs: {
compile: {
options: {
findNestedDependencies: true,
baseUrl: './',
include: 'src/pilot.js',
paths: {
'Emitter': 'empty:'
},
out: 'Pilot.js',
optimize: 'none',
wrap: {
start: `(function (define, factory) {
define(['Emitter'], function (Emitter) {
var defined = {Emitter: Emitter};
var syncDefine = function (name, deps, callback) {
var i = deps.length, depName;
while (i--) {
depName = name.split('/').slice(0, -1).join('/');
deps[i] = defined[deps[i].replace('./', depName ? depName + '/' : '')];
}
defined[name] = callback.apply(null, deps);
};
syncDefine.amd = true;
factory(syncDefine);
return defined['src/pilot.js'];
});
})(typeof define === 'function' && define.amd ? define : function (deps, callback) {
window.Pilot = callback(window.Emitter);
}, function (define) {`,
end: `});`
}
}
}
}
});
grunt.loadNpmTasks('grunt-version');
grunt.loadNpmTasks('grunt-qunit-istanbul');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-requirejs');
// Тестирование
grunt.registerTask('test', ['qunit']);
// Сборка
grunt.registerTask('build', ['requirejs']);
// Минификация
grunt.registerTask('min', ['uglify']);
// Default task.
grunt.registerTask('default', ['version', 'test', 'build', 'min']);
};