forked from j-ulrich/jquery-simulate-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrunt.js
More file actions
120 lines (110 loc) · 3.68 KB
/
grunt.js
File metadata and controls
120 lines (110 loc) · 3.68 KB
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
/*global module:false require:true*/
module.exports = function(grunt) {
"use strict";
var fs = require('fs');
var jshintrcs = {
tests: JSON.parse(fs.readFileSync('tests/.jshintrc'))
};
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\n" : "" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.contributors[0].name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n' +
' */',
'simulate-banner': '/*\n' +
' * jquery.simulate - simulate browser mouse and keyboard events\n' +
' * http://jqueryui.com\n' +
' * \n' +
' * Copyright 2012 jQuery Foundation and other contributors\n' +
' * Dual licensed under the MIT or GPL Version 2 licenses.\n' +
' * http://jquery.org/license\n' +
'*/'
},
lint: {
src: ['src/*.js', 'libs/jquery.simulate.js'],
grunt: 'grunt.js',
tests: ['tests/drag-n-drop.js', 'tests/key-combo.js', 'tests/key-sequence.js', 'tests/testInfrastructure.js']
},
qunit: {
files: ['tests/tests.html']
},
concat: {
'ext-only': {
src: ['src/jquery.simulate.ext.js', 'src/jquery.simulate.drag-n-drop.js', 'src/jquery.simulate.key-sequence.js', 'src/jquery.simulate.key-combo.js'],
dest: 'dist/jquery.simulate.ext.<%= pkg.version %>.js'
},
complete: {
src: ['libs/jquery.simulate.js', 'src/jquery.simulate.ext.js', 'src/jquery.simulate.drag-n-drop.js', 'src/jquery.simulate.key-sequence.js', 'src/jquery.simulate.key-combo.js'],
dest: 'dist/jquery.simulate.ext.<%= pkg.version %>.complete.js'
}
},
min: {
'ext-only': {
src: ['<banner:meta.banner>', '<%= concat["ext-only"].dest %>'],
dest: 'dist/jquery.simulate.ext.<%= pkg.version %>.min.js'
}
},
"multi-banner-min": {
complete: {
src: ['<banner:meta.simulate-banner>', 'libs/jquery.simulate.js', '<banner:meta.banner>', '<%= concat["ext-only"].dest %>'],
dest: 'dist/jquery.simulate.ext.<%= pkg.version %>.complete.min.js'
}
},
watch: {
files: ['<config:lint.src>', '<config:lint.tests>'],
tasks: 'lint qunit'
},
jshint: {
options: {
camelcase: true,
plusplus: true,
forin: true,
noarg: true,
noempty: true,
eqeqeq: true,
bitwise: true,
strict: true,
undef: true,
unused: true,
curly: true,
browser: true,
devel: true,
white: false,
onevar: false,
smarttabs: true
},
globals: {
jQuery: true,
$: true
},
tests: {options: jshintrcs.tests, globals: jshintrcs.tests.globals}
// tests: {jshintrc: 'tests/.jshintrc'}
},
uglify: {}
});
grunt.registerMultiTask('multi-banner-min', 'Minifies files, each proceeded by a banner', function() {
var files = grunt.file.expandFiles(this.file.src);
var output = "";
function returnEmtpyStr() { return ''; }
for (var i=0; i < files.length; i+=1) {
if (i%2 === 0) {
output += grunt.task.directive(files[i], returnEmtpyStr);
}
else {
output += grunt.helper('uglify', grunt.task.directive(files[i], grunt.file.read), grunt.config('uglify'));
}
output += this.data.separator || grunt.utils.linefeed;
}
grunt.file.write(this.file.dest, output);
// Fail task if errors were logged.
if (this.errorCount) { return false; }
// Otherwise, print a success message....
grunt.log.writeln('File "' + this.file.dest + '" created.');
});
// Default task.
grunt.registerTask('default', 'lint qunit concat min multi-banner-min');
};