1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-25 02:42:10 +02:00

@gkatsev updated options customizer and github-release options. closes #2903

This commit is contained in:
Gary Katsevman 2015-12-08 20:30:48 -05:00
parent 565dba8671
commit 08f03c160c
3 changed files with 72 additions and 26 deletions

View File

@ -2,7 +2,7 @@ CHANGELOG
=========
## HEAD (Unreleased)
_(none)_
* @gkatsev updated options customizer and github-release options ([view](https://github.com/videojs/video.js/pull/2903))
--------------------

View File

@ -1,3 +1,4 @@
import {gruntCustomizer, gruntOptionsMaker} from './options-customizer.js';
module.exports = function(grunt) {
require('time-grunt')(grunt);
@ -41,6 +42,19 @@ module.exports = function(grunt) {
]
};
const githubReleaseDefaults = {
options: {
release: {
tag_name: 'v'+ version.full,
name: version.full,
body: require('chg').find(version.full).changesRaw
},
},
files: {
src: [`dist/video-js-${version.full}.zip`] // Files that you want to attach to Release
}
};
/**
* Customizes _.merge behavior in `browserifyGruntOptions` to concatenate
* arrays. This can be overridden on a per-call basis to
@ -52,11 +66,7 @@ module.exports = function(grunt) {
* @param {Mixed} sourceValue
* @return {Object}
*/
function browserifyGruntCustomizer(objectValue, sourceValue) {
if (Array.isArray(objectValue)) {
return objectValue.concat(sourceValue);
}
}
const browserifyGruntCustomizer = gruntCustomizer;
/**
* Creates a unique object of Browserify Grunt task options.
@ -70,9 +80,10 @@ module.exports = function(grunt) {
*
* @return {Object}
*/
function browserifyGruntOptions(options = null, customizer = browserifyGruntCustomizer) {
return _.merge({}, browserifyGruntDefaults, options, customizer);
}
const browserifyGruntOptions = gruntOptionsMaker(browserifyGruntDefaults, browserifyGruntCustomizer);
const githubReleaseCustomizer = gruntCustomizer;
const githubReleaseOptions = gruntOptionsMaker(githubReleaseDefaults, githubReleaseCustomizer);
/**
* Creates processor functions for license banners.
@ -296,28 +307,14 @@ module.exports = function(grunt) {
password: process.env.VJS_GITHUB_TOKEN
}
},
release: {
release: githubReleaseOptions(),
prerelease: githubReleaseOptions({
options: {
release: {
tag_name: 'v'+ version.full,
name: version.full,
body: require('chg').find(version.full).changesRaw
}
}
},
prerelease: {
options: {
release: {
tag_name: 'v'+ version.full,
name: version.full,
body: require('chg').find(version.full).changesRaw,
prerelease: true
}
}
},
files: {
src: [`dist/video-js-${version.full}.zip`] // Files that you want to attach to Release
}
})
},
browserify: {
options: browserifyGruntOptions(),

View File

@ -0,0 +1,49 @@
import _ from 'lodash-compat';
/**
* Customizes _.merge behavior in `gruntOptions` to concatenate
* arrays. This can be overridden on a per-call basis to
*
* @see https://lodash.com/docs#merge
* @function GruntCustomizer
* @private
* @param {Mixed} objectValue
* @param {Mixed} sourceValue
* @return {Object}
*/
function gruntCustomizer(objectValue, sourceValue) {
if (Array.isArray(objectValue)) {
return objectValue.concat(sourceValue);
}
}
/**
* Creates a gruntOptions instance for the specific defaultOptions and gruntCustomizer
*
* @function browserifyGruntOptions
* @private
* @param {Object} [options]
* @param {Function} [customizer=gruntCustomizer]
* If the default array-concatenation behavior is not desireable,
* pass _.noop or a unique customizer (https://lodash.com/docs#merge).
*
* @return {Function}
*/
function gruntOptionsMaker(defaultOptions, gruntCustomizer) {
/**
* Creates a unique object of Browserify Grunt task options.
*
* @function gruntOptions
* @private
* @param {Object} [options]
* @param {Function} [customizer=browserifyGruntCustomizer]
* If the default array-concatenation behavior is not desireable,
* pass _.noop or a unique customizer (https://lodash.com/docs#merge).
*
* @return {Object}
*/
return function gruntOptions(options = null, customizer = gruntCustomizer) {
return _.merge({}, defaultOptions, options, customizer);
}
};
export { gruntCustomizer, gruntOptionsMaker };