forked from jappix/jappix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
136 lines (116 loc) · 3.2 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
/*
* Jappix
* Tasks (uses GruntJS)
*
* Copyright 2013, Jappix
* Author: Valérian Saliou <[email protected]>
*/
module.exports = function(grunt) {
// Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Task: CSSLint
csslint: {
all: {
options: {
/*
* CSS Lint Options
* Reference: https://github.com/gruntjs/grunt-contrib-csslint/blob/master/README.md#options
*/
'important': false,
'duplicate-background-images': false,
'star-property-hack': false,
'adjoining-classes': false,
'box-model': false,
'qualified-headings': false,
'unique-headings': false,
'floats': false,
'font-sizes': false,
'ids': false,
'overqualified-elements': false,
'known-properties': false,
'unqualified-attributes': false,
'universal-selector': false
},
src: [
'./app/stylesheets/*.css',
// Ignored files
'!./app/stylesheets/ie.css',
'!./app/stylesheets/*-ie.css',
'!./app/stylesheets/ios.css'
]
}
},
// Task: JSHint
jshint: {
files: ['./app/javascripts/*.js'],
options: {
ignores: [
'./app/javascripts/jquery.js',
'./app/javascripts/jquery.*.js',
'./app/javascripts/jsjac.js',
'./app/javascripts/jsjac.*.js',
'./app/javascripts/jxhr.js',
'./app/javascripts/browser-detect.js',
'./app/javascripts/base64.js',
'./app/javascripts/datejs.js',
'./app/javascripts/ios.js'
]
}
},
// Task PHPLint
phplint: {
all: [
'./index.php',
'./server/*.php',
// Ignored files
'!./server/drawsvgchart.php',
'!./server/gettext.php',
'!./server/jsmin.php',
'!./server/srand.php'
]
}
});
// Load plugins
grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-phplint');
// Map tasks
var GRUNT_TASKS_TEST = {
all: [['lint',0]]
};
var GRUNT_TASKS_LINT = {
css: [['csslint',0]],
js: [['jshint',0]],
php: [['phplint',0]]
};
// Register tasks
grunt.registerTask('default', function() {
return grunt.warn('Usage:' + '\n\n' + 'test - grunt test' + '\n\n');
});
grunt.registerTask('test', function() {
for(t in GRUNT_TASKS_TEST) {
for(i in GRUNT_TASKS_TEST[t]) {
grunt.task.run(GRUNT_TASKS_TEST[t][i][0] + (GRUNT_TASKS_TEST[t][i][1] ? (':' + t) : ''));
}
}
});
grunt.registerTask('lint', function(t) {
var lint_t_all = [];
if(t == null) {
for(t in GRUNT_TASKS_LINT) {
lint_t_all.push(t);
}
} else if(typeof GRUNT_TASKS_LINT[t] != 'object') {
return grunt.warn('Invalid lint target name.\n');
} else {
lint_t_all.push(t);
}
for(c in lint_t_all) {
t = lint_t_all[c];
for(i in GRUNT_TASKS_LINT[t]) {
grunt.task.run(GRUNT_TASKS_LINT[t][i][0] + (GRUNT_TASKS_LINT[t][i][1] ? (':' + t) : ''));
}
}
});
};