-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
144 lines (141 loc) · 4.04 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
'use strict';
/*
* lowkie
* http://github.com/typesettin/lowkie
*
* Copyright (c) 2017 Yaw Joseph Etse. All rights reserved.
*/
const path = require('path');
const testPaths = ['./test/**/*.js',];
module.exports = function (grunt) {
grunt.initConfig({
jsbeautifier: {
files: ['<%= jshint.all %>',],
options: {
config: '.jsbeautify',
},
},
mocha_istanbul: {
coveralls: {
src: testPaths, // multiple folders also works
options: {
coverageFolder: 'coverage', // will check both coverage folders and merge the coverage results
coverage:true, // this will make the grunt.event.on('coverage') event listener to be triggered
check: {
lines: 5,
branches: 5,
functions: 5,
statements: 5,
},
// root: './lib', // define where the cover task should consider the root of libraries that are covered by tests
reportFormats: ['cobertura', 'lcovonly',],
},
},
},
istanbul_check_coverage: {
default: {
options: {
coverageFolder: 'coverage', // will check both coverage folders and merge the coverage results
check: {
lines: 80,
branches: 80,
functions: 80,
statements: 80,
},
},
},
},
coveralls: {
// Options relevant to all targets
options: {
// When true, grunt-coveralls will only print a warning rather than
// an error, to prevent CI builds from failing unnecessarily (e.g. if
// coveralls.io is down). Optional, defaults to false.
force: false,
},
all: {
// LCOV coverage file (can be string, glob or array)
src: 'coverage/*.info',
options: {
// Any options for just this target
},
},
},
simplemocha: {
options: {
globals: ['should', 'navigator', 'x',],
timeout: 3000,
ignoreLeaks: true,
ui: 'bdd',
reporter: 'spec',
},
all: {
src: testPaths,
},
},
jsdoc: {
dist: {
src: ['lib/**/*.js', 'index.js',],
options: {
destination: 'doc/html',
configure: 'jsdoc.json',
},
},
},
browserify: {
dist: {
files: [ {
expand: true,
// cwd: 'scripts',
src: [ 'index.js', ],
dest: './dist',
rename: function (dest, src) {
var finallocation = path.join(dest, src);
finallocation = finallocation.replace('index.js', 'lowkie.js');
// finallocation = finallocation.replace('resources', 'public');
finallocation = path.resolve(finallocation);
return finallocation;
},
}, ],
options: {
transform: [
[ 'babelify', {
presets: [ 'es2015', 'es2016', 'es2017', ],
}, ],
],
},
},
},
uglify: {
options: {
sourceMap: true,
compress: {
drop_console: false,
},
},
all: {
files: [{
expand: true,
// cwd: 'scripts',
src: ['dist/lowkie.js',],
dest: './dist',
rename: function (dest, src) {
var finallocation = path.join(dest, src);
finallocation = finallocation.replace('lowkie.js', 'lowkie.min.js');
finallocation = path.resolve(finallocation);
return finallocation;
},
},],
},
},
});
// Loading dependencies
for (var key in grunt.file.readJSON('package.json').devDependencies) {
if (key.indexOf('grunt') === 0 && key !== 'grunt') {
grunt.loadNpmTasks(key);
}
}
grunt.registerTask('doc', 'jsdoc');
grunt.registerTask('test', 'mocha_istanbul');
grunt.registerTask('default', [/*'lint',*/'test', 'browserify', 'doc', 'uglify', ]);
};