Skip to content

Commit

Permalink
@misteroneill create video.novtt.js in dist builds. closes #2447
Browse files Browse the repository at this point in the history
  • Loading branch information
misteroneill authored and dmlap committed Aug 10, 2015
1 parent 67c0d99 commit c0673d2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ CHANGELOG
* @misteroneill removed the deprecated Component init method ([view](https://github.com/videojs/video.js/pull/2427))
* @misteroneill restore videojs.formatTime ([view](https://github.com/videojs/video.js/pull/2420))
* @misteroneill include child components with `true` in options ([view](https://github.com/videojs/video.js/pull/2424))
* @misteroneill create video.novtt.js in dist builds ([view](https://github.com/videojs/video.js/pull/2447))

--------------------

Expand Down
8 changes: 4 additions & 4 deletions build/license-header.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @license
* Video.js <%= pkg.version %> <http://videojs.com/>
* <%= pkg.copyright %>
* Video.js <%= version %> <http://videojs.com/>
* <%= copyright %>
* Available under Apache License Version 2.0
* <https://github.com/videojs/video.js/blob/master/LICENSE>
*
<% if (includesVtt) { %> *
* Includes vtt.js <https://github.com/mozilla/vtt.js>
* Available under Apache License Version 2.0
* <https://github.com/mozilla/vtt.js/blob/master/LICENSE>
*/
<% } %> */
50 changes: 48 additions & 2 deletions grunt.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module.exports = function(grunt) {
require('time-grunt')(grunt);

let _ = require('lodash-compat');
let pkg = grunt.file.readJSON('package.json');
let license = grunt.file.read('build/license-header.txt');
let bannerCommonData = _.pick(pkg, ['version', 'copyright']);
let verParts = pkg.version.split('.');
let version = {
full: pkg.version,
Expand All @@ -11,6 +13,22 @@ module.exports = function(grunt) {
patch: verParts[2]
};

/**
* Creates processor functions for license banners.
*
* @private
* @param {Object} data Custom data overriding `bannerCommonData`. Will
* not be mutated.
* @return {Function} A function which returns a processed grunt template
* using an object constructed from `bannerCommonData`
* and the `data` argument.
*/
let createLicenseProcessor = (data) => function () {
return grunt.template.process(license, {
data: _.merge({}, bannerCommonData, data)
});
};

version.majorMinor = `${version.major}.${version.minor}`;
grunt.vjsVersion = version;

Expand Down Expand Up @@ -49,6 +67,7 @@ module.exports = function(grunt) {
},
build: {
files: {
'build/temp/alt/video.novtt.min.js': 'build/temp/alt/video.novtt.js',
'build/temp/video.min.js': 'build/temp/video.js'
}
}
Expand Down Expand Up @@ -224,7 +243,6 @@ module.exports = function(grunt) {
debug: true,
standalone: 'videojs'
},
banner: license,
plugin: [
['browserify-derequire']
],
Expand Down Expand Up @@ -294,6 +312,13 @@ module.exports = function(grunt) {
}
},
concat: {
novtt: {
options: {
separator: '\n'
},
src: ['build/temp/video.js'],
dest: 'build/temp/video.novtt.js'
},
vtt: {
options: {
separator: '\n',
Expand All @@ -318,6 +343,24 @@ module.exports = function(grunt) {
'watch',
'browserify:watch'
]
},
usebanner: {
novtt: {
options: {
process: createLicenseProcessor({includesVtt: false})
},
files: {
src: ['build/temp/alt/video.novtt.js']
}
},
vtt: {
options: {
process: createLicenseProcessor({includesVtt: true})
},
files: {
src: ['build/temp/video.js']
}
}
}
});

Expand All @@ -332,8 +375,11 @@ module.exports = function(grunt) {
'jshint',
'browserify:build',
'exorcise:build',
'copy:novtt',
'concat:novtt',
'concat:vtt',
'copy:novtt',
'usebanner:novtt',
'usebanner:vtt',
'uglify',

'sass',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"es5-shim": "^4.1.3",
"grunt": "^0.4.4",
"grunt-aws-s3": "^0.12.1",
"grunt-banner": "^0.3.1",
"grunt-banner": "^0.4.0",
"grunt-browserify": "3.5.1",
"grunt-cli": "~0.1.0",
"grunt-concurrent": "^1.0.0",
Expand Down

0 comments on commit c0673d2

Please sign in to comment.