forked from jensommerville/pilotfish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grunt.js
108 lines (93 loc) · 3.74 KB
/
grunt.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
/* vim: set expandtab tabstop=4: */
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: '/* <%= pkg.description %>, v<%= pkg.version %> <%= pkg.homepage %>\n' +
'Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>, MIT license ' +
'<%= pkg.licenses[0].url %> */'
},
// Run functional tests with phantomjs and casper
casperjs: {
files: ['plugins/*/test/casperjs-*.js']
},
annotate: {
files: ['pilotfish.js', 'plugins/*/pilotfish-*.js']
},
// run jshint on the files, with the options described below. Different globals defined based on file type
// 'node' for files that are run by node.js (module, process, etc.)
// 'browser' for files that are run by a browser (window, document, etc.)
// 'qunit', ok, equal, etc.
lint: {
node: ['grunt.js', 'tasks/*.js', 'plugins/*/test/casper*.js'],
browser: ['pilotfish.js', 'test/*.js', 'plugins/*/pilotfish-*.js', 'lib/qunit/pilotfish-common.js']
},
jshint: {
// Apply to all js files
options: {
curly: true,
expr: true,
forin: true,
indent: false,
loopfunc: true,
latedef: false,
noarg: true,
noempty: true, // debatable
sub: true,
trailing: true,
undef: true, // Really. Leave it
unused: true
},
globals: {},
// Just for the 'node' src files
node: {
globals: {module: true, require: true, __dirname: true, document: true }
},
// Just for the 'browser' src files
browser: {
// Let's be very strict here
globals: {jQuery: true, QUnit: true, window: true, document: true, location: true, Pilotfish: true}
}
},
// Minify pilotfish src to pilotfish.min.js, prepending a banner
min: {
dist: {
src: ['<banner:meta.banner>', 'pilotfish.js'],
dest: 'pilotfish.min.js'
}
},
// Run qunit on all the qunit test files, using phantomjs
qunit: {
files: ['test/*.html', 'plugins/*/test/qunit-*.html']
},
spell: {
files: ['doc/*', '*.md', 'pilotfish.js', 'plugins/*/*.md']
},
// Every time a js file is changed, run lint and qunit
watch: {
files: ['grunt.js', 'tasks/*.js', 'pilotfish.js', 'test/**/*',
'plugins/**/*', 'lib/qunit/pilotfish-common.js'],
tasks: 'lint qunit'
}
});
var connect = require('connect');
grunt.registerTask('webserver', 'Start a custom static web server.', function () {
this.async();
grunt.log.writeln('Starting static web server in "www-root" on port 1234.');
connect(connect['static'](__dirname)).listen(1234);
});
// Load NPM tasks
grunt.loadNpmTasks('grunt-casperjs');
grunt.loadNpmTasks('grunt-spell');
// Load all the tasks inside the tasks/ directory
grunt.loadTasks('tasks');
// Alias test
grunt.registerTask('test', 'qunit server casperjs');
// This is what gets run when you don't specify an argument for grunt.
// Should be non destructive
grunt.registerTask('default', 'lint test');
// Release tasks
grunt.registerTask('commitRelease', 'lint test min annotate');
grunt.registerTask('release', 'lint test build min annotate gitRelease cdnPublish');
};