This repository has been archived by the owner on Mar 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGruntfile.js
95 lines (81 loc) · 2.77 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
jshintrc: true
},
all: [
'lib/*.js'
]
},
node_tap: {
default_options: {
options: {
outputType: 'failures',
outputTo: 'console'
},
files: {
'tests': ['test/*.js']
}
}
},
uglify: {
options: {
banner: '// o.js : DEVELOPMENT VERSION : https://o-js.com : MIT License\n',
sourceMap: true
},
build: {
src: 'o.js',
dest: 'o.min.js'
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-node-tap');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('test', ['node_tap']);
grunt.registerTask('minify', ['uglify']);
// An exec wrapper that throws an error on error.
var nativeExec = require('child_process').exec;
var exec = function (command, cb) {
grunt.log.writeln('Running: ' + command);
nativeExec(command, function (error, stdout, stderr) {
if (error === null) {
cb( stdout );
}
else {
grunt.log.write( stderr );
throw new Error('Error running: ' + command);
}
});
};
grunt.registerTask(
'combine',
'Combine lib/*.js into a single o.js.',
function() { exec('bin/combine', this.async()); }
);
grunt.registerTask(
'fix-doc-headers',
'Fixup doc headers to have a menu and TOC.',
function() { exec('bin/fix-doc-headers', this.async()); }
);
grunt.registerTask(
'tag',
'Determine next version, modify files to reference it, and commit the tag.',
function (next) { exec('bin/tag --no-prompt --next=' + next, this.async()); }
);
grunt.registerTask('default', ['lint', 'test', 'combine', 'minify', 'fix-doc-headers']);
grunt.registerTask('release-major', ['default', 'tag:major']);
grunt.registerTask('release-minor', ['default', 'tag:minor']);
grunt.registerTask('release-patch', ['default', 'tag:patch']);
grunt.registerTask(
'publish-npm',
'Publish current checked out release to NPM.',
function () { exec('npm publish', this.async()); }
);
// Note that Bower does not need a publish task as it automatically
// finds new releases by looking at the tags in GitHub.
grunt.registerTask('publish', ['publish-npm']);
};