1
0

config.js 763 B

1234567891011121314151617181920212223
  1. /**
  2. * Wrapper around amd-config-builder.
  3. * Can be used in cli and in grunt task.
  4. */
  5. var configBuilder = require('amd-config-builder'),
  6. path = require('path'),
  7. fs = require('fs');
  8. exports.writeConfig = function (searchDir, fileForConfig) {
  9. searchDir = searchDir || path.join(__dirname, '../../..');
  10. fileForConfig = fileForConfig || 'config.js';
  11. configBuilder.produceConfigObject(searchDir, function (err, result) {
  12. if (err) throw err;
  13. var text = "/* DO NOT EDIT! This file is generated. */\n" +
  14. "\n" +
  15. "require.config(" + JSON.stringify(result, null, 2) + ");";
  16. fs.writeFile(path.join(searchDir, fileForConfig), text, function (err) {
  17. if (err) throw err;
  18. });
  19. });
  20. };