Added helper function for getting JS assets

This commit is contained in:
David Baldwynn 2017-04-22 21:10:37 -07:00 committed by GitHub
parent 2fb96dd68c
commit 0944541247

View file

@ -73,17 +73,34 @@ module.exports.getBowerOtherAssets = function() {
}; };
/** /**
* Get the modules JavaScript files * Helper Function for getJavascriptAssets and getFormJavaScriptAssets
*/ */
module.exports.getJavaScriptAssets = function(includeTests) { var getAssets = function(includeTests, isFormJS){
var output = this.getGlobbedFiles(this.assets.js, 'public/', 'static/'); var unit_tests, js_assets;
if(isFormJS) {
js_assets = this.assets.form_js;
unit_tests = this.assets.form_unit_tests;
} else {
js_assets = this.assets.js;
unit_tests = this.assets.unit_tests;
}
var output = this.getGlobbedFiles(js_assets, 'public/', 'static/');
// To include tests // To include tests
if (includeTests) { if (includeTests) {
output = _.union(output, this.getGlobbedFiles(this.assets.unit_tests)); output = _.union(output, this.getGlobbedFiles(unit_tests));
} }
return output; return output;
}
/**
* Get the modules JavaScript files
*/
module.exports.getJavaScriptAssets = function(includeTests) {
return getAssets(includeTests, false);
}; };
/** /**
@ -98,12 +115,5 @@ module.exports.getCSSAssets = function() {
* Get the modules Form JavaScript files * Get the modules Form JavaScript files
*/ */
module.exports.getFormJavaScriptAssets = function(includeTests) { module.exports.getFormJavaScriptAssets = function(includeTests) {
var output = this.getGlobbedFiles(this.assets.form_js, 'public/', 'static/'); return getAssets(includeTests, true);
// To include tests
if (includeTests) {
output = _.union(output, this.getGlobbedFiles(this.assets.form_unit_tests));
}
return output;
}; };