combo.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. 'use strict';
  6. var theme = require('../tools/files-router').get('themes'),
  7. path = require('./path');
  8. /**
  9. * Define Combos for repetitive code.
  10. */
  11. module.exports = {
  12. collector: function (themeName) {
  13. var cmdPlus = /^win/.test(process.platform) ? ' & ' : ' && ',
  14. command = 'grunt --force clean:' + themeName + cmdPlus;
  15. command = command + 'php bin/magento dev:source-theme:deploy ' +
  16. theme[themeName].files.join(' ') +
  17. ' --type=less' +
  18. ' --locale=' + theme[themeName].locale +
  19. ' --area=' + theme[themeName].area +
  20. ' --theme=' + theme[themeName].name;
  21. return command;
  22. },
  23. autopath: function (themeName, folder) {
  24. return folder +
  25. theme[themeName].area + '/' +
  26. theme[themeName].name + '/' +
  27. theme[themeName].locale + '/';
  28. },
  29. lessFiles: function (themeName) {
  30. var lessStringArray = [],
  31. cssStringArray = [],
  32. lessFiles = {},
  33. i = 0;
  34. for (i; i < theme[themeName].files.length; i++) {
  35. cssStringArray[i] = path.pub +
  36. theme[themeName].area + '/' +
  37. theme[themeName].name + '/' +
  38. theme[themeName].locale + '/' +
  39. theme[themeName].files[i] + '.css';
  40. lessStringArray[i] = path.pub +
  41. theme[themeName].area + '/' +
  42. theme[themeName].name + '/' +
  43. theme[themeName].locale + '/' +
  44. theme[themeName].files[i] + '.less';
  45. lessFiles[cssStringArray[i]] = lessStringArray[i];
  46. }
  47. return lessFiles;
  48. }
  49. };