You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.4 KiB

  1. /*******************************
  2. Set-up
  3. *******************************/
  4. var
  5. defaults = require('../defaults'),
  6. path = require('path')
  7. ;
  8. /*******************************
  9. Exports
  10. *******************************/
  11. module.exports = {
  12. // adds additional derived values to a config object
  13. addDerivedValues: function(config) {
  14. config = config || defaults;
  15. /*--------------
  16. File Paths
  17. ---------------*/
  18. // resolve source paths
  19. for(var folder in config.paths.source) {
  20. if(config.paths.source.hasOwnProperty(folder)) {
  21. config.paths.source[folder] = path.normalize(config.base + config.paths.source[folder]);
  22. }
  23. }
  24. // resolve output paths
  25. for(folder in config.paths.output) {
  26. if(config.paths.output.hasOwnProperty(folder)) {
  27. config.paths.output[folder] = path.normalize(config.base + config.paths.output[folder]);
  28. }
  29. }
  30. // resolve "clean" command path
  31. config.paths.clean = config.base + config.paths.clean;
  32. /*--------------
  33. CSS URLs
  34. ---------------*/
  35. // determine asset paths in css by finding relative path between themes and output
  36. // force forward slashes
  37. config.paths.assets = {
  38. source : '../../themes', // source asset path is always the same
  39. uncompressed : path.relative(config.paths.output.uncompressed, config.paths.output.themes).replace(/\\/g,'/'),
  40. compressed : path.relative(config.paths.output.compressed, config.paths.output.themes).replace(/\\/g,'/'),
  41. packaged : path.relative(config.paths.output.packaged, config.paths.output.themes).replace(/\\/g,'/')
  42. };
  43. /*--------------
  44. Permission
  45. ---------------*/
  46. if(config.permission) {
  47. config.hasPermissions = true;
  48. }
  49. else {
  50. // pass blank object to avoid causing errors
  51. config.permission = {};
  52. config.hasPermissions = false;
  53. }
  54. /*--------------
  55. Globs
  56. ---------------*/
  57. if(!config.globs) {
  58. config.globs = {};
  59. }
  60. // takes component object and creates file glob matching selected components
  61. config.globs.components = (typeof config.components == 'object')
  62. ? (config.components.length > 1)
  63. ? '{' + config.components.join(',') + '}'
  64. : config.components[0]
  65. : '{' + defaults.components.join(',') + '}'
  66. ;
  67. return config;
  68. }
  69. };