forked from mozilla/vtt.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
129 lines (113 loc) · 3.29 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
121
122
123
124
125
126
127
128
129
var exec = require("child_process").exec,
distFiles = [
"lib/vttcue.js",
"lib/vttregion.js",
"lib/vtt.js",
"node_modules/text-encoding/lib/encoding.js"
],
banner = "/* <%= pkg.name %> - v<%= pkg.version %> (<%= pkg.homepage %>) " +
"built on <%= grunt.template.today('dd-mm-yyyy') %> */\n"
module.exports = function( grunt ) {
grunt.initConfig({
pkg: grunt.file.readJSON( "package.json" ),
jshint: {
options: {
esnext: true,
indent: 2,
expr: true,
camelcase: true,
curly: true,
eqeqeq: true,
newcap: true,
unused: true,
trailing: true,
browser: true,
node: true
},
files: [ "lib/*", "tests/**/*.js" ]
},
uglify: {
options: {
banner: banner
},
dist: {
files: {
"dist/vtt.min.js": distFiles
}
},
dev: {
files: {
"dev_build/vtt.min.js": distFiles
}
}
},
concat: {
options: {
banner: banner + "\n"
},
dist: {
src: distFiles,
dest: "dist/vtt.js"
},
dev: {
src: distFiles,
dest: "dev_build/vtt.js"
}
},
bump: {
options: {
files: [ "package.json", "bower.json" ],
updateConfigs: [],
commit: true,
commitMessage: "Release v%VERSION%",
commitFiles: [ "package.json", "bower.json", "dist/*" ],
createTag: true,
tagName: "v%VERSION%",
tagMessage: "Version %VERSION%",
push: true,
pushTo: "[email protected]:mozilla/vtt.js.git",
}
},
mochaTest: {
test: {
options: {
reporter: "spec",
slow: "15000",
timeout: "120000"
},
src: [ "tests/**/*.js" ]
}
}
});
function execCmd(cmd, onExecuted) {
exec( cmd, function(error, stdout, stderr) {
error && console.error(error);
stderr && console.error(stderr);
stdout && console.log(stdout);
onExecuted();
});
}
grunt.loadNpmTasks( "grunt-contrib-jshint" );
grunt.loadNpmTasks( "grunt-contrib-uglify" );
grunt.loadNpmTasks( "grunt-contrib-concat" );
grunt.loadNpmTasks( "grunt-bump" );
grunt.loadNpmTasks( "grunt-mocha-test" );
grunt.registerTask( "build", [ "uglify:dist", "concat:dist" ] );
grunt.registerTask( "dev-build", [ "uglify:dev", "concat:dev" ])
grunt.registerTask( "default", [ "jshint", "dev-build", "mochaTest" ]);
grunt.registerTask( "stage-dist", "Stage dist files.", function() {
execCmd( "git add dist/*", this.async() );
});
grunt.registerTask( "reload-pkg", "Reload the package.json config.", function() {
grunt.config( "pkg", grunt.file.readJSON( "package.json" ) );
});
grunt.registerTask( "release", "Build the distributables and bump the version.", function(arg) {
grunt.task.run( "bump-only:" + arg, "reload-pkg", "build", "stage-dist", "bump-commit" );
});
grunt.registerTask( "cue2json", "Run cue2json.", function(path, opts) {
execCmd( "./bin/cue2json.js -v " + path + (opts && " -" + opts || ""), this.async() );
});
grunt.registerTask( "run", "Build dev-build and run cue2json.", function(path, opts) {
grunt.task.run( "dev-build", "cue2json:" + path + ":" + opts );
});
};