forked from jaridmargolin/formatter.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
99 lines (96 loc) · 2.67 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
all: [
'Gruntfile.js',
'src/**/*.js',
'test/**/*.js',
'test/**/**/*.js',
'lib/formatter.js',
'lib/jquery.formatter.js'
],
options: {
ignores: [
'src/tmpls/intro.js',
'src/tmpls/outro.js',
'src/tmpls/jquery.intro.js',
'src/tmpls/jquery.outro.js'
],
force: true,
es3: true,
smarttabs: true,
// Bad line breaking before '?'.
'-W014': true,
// Expected a conditional expression and instead saw an assignment.
'-W084': true
}
},
concat: {
options: {
banner: '/*!\n' +
' * v<%= pkg.version %>\n' +
' * Copyright (c) 2013 First Opinion\n' +
' * formatter.js is open sourced under the MIT license.\n' +
' *\n' +
' * thanks to digitalBush/jquery.maskedinput for some of the trickier\n' +
' * keycode handling\n' +
' */ \n\n',
process: function(src, filepath) {
if (!/tmpls\/.*\.js/.test(filepath)) {
// Remove contents between Exclude Start and Exclude End
src = src.replace( /\/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\//ig, '');
// Rewrite module.exports to local var
src = src.replace(/module.exports\s=/g, 'var');
}
// Return final
return src;
},
stripBanners: true
},
vanilla: {
src: [
'src/tmpls/intro.js',
'src/formatter.js',
'src/pattern.js',
'src/pattern-matcher.js',
'src/inpt-sel.js',
'src/utils.js',
'src/tmpls/outro.js'
],
dest: 'lib/formatter.js'
},
jquery: {
src: [
'src/tmpls/jquery.intro.js',
'src/formatter.js',
'src/pattern.js',
'src/pattern-matcher.js',
'src/inpt-sel.js',
'src/utils.js',
'src/tmpls/jquery.outro.js'
],
dest: 'lib/jquery.formatter.js'
}
},
uglify: {
options: {
preserveComments: 'some'
},
vanilla: {
src: 'lib/formatter.js',
dest: 'lib/formatter.min.js'
},
jquery: {
src: 'lib/jquery.formatter.js',
dest: 'lib/jquery.formatter.min.js'
}
}
});
// Load plugins
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Tasks
grunt.registerTask('default', ['concat', 'uglify', 'jshint']);
};