load-files.js 620 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. var copyProps = require('copy-props');
  3. var path = require('path');
  4. function loadConfigFiles(configFiles, configFileOrder) {
  5. var config = {};
  6. configFileOrder.forEach(loadFile);
  7. function loadFile(key) {
  8. var filePath = configFiles[key];
  9. if (!filePath) {
  10. return;
  11. }
  12. copyProps(require(filePath), config, convert);
  13. function convert(loadedInfo) {
  14. if (loadedInfo.keyChain === 'flags.gulpfile') {
  15. return path.resolve(path.dirname(filePath), loadedInfo.value);
  16. }
  17. return loadedInfo.value;
  18. }
  19. }
  20. return config;
  21. }
  22. module.exports = loadConfigFiles;