-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathGruntfile.js
120 lines (105 loc) · 3.33 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
module.exports = function( grunt ) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/*\n <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n' +
' Built: <%= grunt.template.today("yyyy-mm-dd hh:mm") %> - ' + '<%= pkg.homepage %>\n' +
' Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' Licensed <%= pkg.license %> \n*/\n\n\n',
version: ' modules.version = \'<%= pkg.version %>\';'
},
buildfile: {
version: {
dest: 'lib/version.js',
content: '<%= meta.version %>'
}
},
example: {
'compiled.js': ['lib/*.js'],
},
concat: {
dist: {
options: {
banner: '<%= meta.banner %>',
process: function(src, filename) {
console.log(filename);
if(filename.indexOf('maps') > -1){
src = src.replace('modules.maps = (modules.maps)? modules.maps : {};','');
}
if(filename.indexOf('wrap') === -1){
src = src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '');
src = src.replace('var Modules = (function (modules) {','');
src = src.replace('return modules;','');
src = src.replace('} (Modules || {}));','');
if(src.indexOf('*/') > -1){
src = '\n ' + src.substr(src.indexOf('*/')+2).trim() + '\n';
}
}
return src;
},
},
files:{
'lib/index.js': [
'wrap/wrap-start.js',
'lib/version.js',
'node_modules/microformat-shiv/lib/living-standard.js',
'node_modules/microformat-shiv/lib/parser.js',
'node_modules/microformat-shiv/lib/parser-implied.js',
'node_modules/microformat-shiv/lib/parser-includes.js',
'node_modules/microformat-shiv/lib/parser-rels.js',
'node_modules/microformat-shiv/lib/utilities.js',
'lib/domutils.js',
'lib/url.js',
'node_modules/microformat-shiv/lib/isodate.js',
'node_modules/microformat-shiv/lib/dates.js',
'node_modules/microformat-shiv/lib/text.js',
'node_modules/microformat-shiv/lib/html.js',
'node_modules/microformat-shiv/lib/maps/*.js',
'wrap/wrap-end.js',
]
}
}
},
jshint: {
files: ['lib/**/*.js','wrap/**/*.js','Gruntfile.js','lib/index.js'],
options: {
curly: true,
eqeqeq: true,
latedef: true,
noarg: true,
undef: true,
unused: true,
boss: true,
eqnull: true,
browser: true,
node: true,
quotmark: 'single',
moz: true,
predef: [ 'Microformats', 'define', 'modules', 'URI', 'cheerio' ]
},
globals: {}
},
mocha_phantomjs: {
options:{
'reporter': 'list',
},
all: ['test/mocha-tests.html']
},
watch: {
files: ['lib/domutils.js','wrap/**/*.js','node_modules/microformat-shiv/lib/**/*.js','Gruntfile.js','package.json'],
tasks: ['buildfile', 'concat:dist']
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
// very simple files creator
grunt.task.registerMultiTask('buildfile', function() {
grunt.file.write(this.data.dest, this.data.content, {encoding: 'utf8'});
grunt.log.writeln('File ' + this.data.dest + 'created');
});
// Default task.
grunt.registerTask( 'default', ['buildfile', 'concat:dist']);
};