text: 'use strict';
  
  /**
   * Module dependencies.
   */
  var _ = require('lodash'),
  	glob = require('glob');
  
  /**
   * Load app configurations
   */
  module.exports = _.extend(
  	require('./env/all'),
  	require('./env/' + process.env.NODE_ENV) || {}
  );
  
  /**
   * Get files by glob patterns
   */
  module.exports.getGlobbedFiles = function(globPatterns, removeRoot) {
  	// For context switching
  	var _this = this;
  
  	// URL paths regex
  	var urlRegex = new RegExp('^(?:[a-z]+:)?\/\/', 'i');
  
  	// The output array
  	var output = [];
  
  	// If glob pattern is array so we use each pattern in a recursive way, otherwise we use glob 
  	if (_.isArray(globPatterns)) {
  		globPatterns.forEach(function(globPattern) {
  			output = _.union(output, _this.getGlobbedFiles(globPattern, removeRoot));
  		});
  	} else if (_.isString(globPatterns)) {
  		if (urlRegex.test(globPatterns)) {
  			output.push(globPatterns);
  		} else {
  			glob(globPatterns, {
  				sync: true
  			}, function(err, files) {
  				if (removeRoot) {
  					files = files.map(function(file) {
  						return file.replace(removeRoot, '');
  					});
  				}
  
  				output = _.union(output, files);
  			});
  		}
  	}
  
  	return output;
  };
  
  /**
   * Get the modules JavaScript files
   */
  module.exports.getJavaScriptAssets = function(includeTests) {
  	var output = this.getGlobbedFiles(this.assets.lib.js.concat(this.assets.js), 'public/');
  
  	// To include tests
  	if (includeTests) {
  		output = _.union(output, this.getGlobbedFiles(this.assets.tests));
  	}
  
  	return output;
  };
  
  /**
   * Get the modules CSS files
   */
  module.exports.getCSSAssets = function() {
  	var output = this.getGlobbedFiles(this.assets.lib.css.concat(this.assets.css), 'public/');
  	return output;
  };
  
  //================= start our custom functions=====================================
  
  /**
   * Get the modules JavaScript files for admin
   */
  
  module.exports.getAdminJavaScriptAssets = function(includeTests) {
  	var output = this.getGlobbedFiles(this.assets.lib.js.concat(this.assets.adminJs), 'public/');
  
  	// To include tests
  	if (includeTests) {
  		output = _.union(output, this.getGlobbedFiles(this.assets.tests));
  	}
  
  	return output;
  };
  
  /**
   * Get the modules CSS files for admin
   */
  module.exports.getAdminCSSAssets = function() {
  	var output = this.getGlobbedFiles(this.assets.lib.css.concat(this.assets.adminCss), 'public/');
  	return output;
  };
  
  
  /**
   * Get the modules JavaScript files for Theme
   */
  
  module.exports.getThemeJavaScriptAssets = function(includeTests) {
  	var output = this.getGlobbedFiles(this.assets.themeJs, 'public/');
  
  	return output;
  };
  
  /**
   * Get the modules CSS files for Theme
   */
  module.exports.getThemeCSSAssets = function() {
  	var output = this.getGlobbedFiles(this.assets.themeCss, 'public/');
  	return output;
  };
  
  //================= End our custom functions=====================================
  