update.js 871 B

12345678910111213141516171819202122232425262728293031
  1. var fs = require('fs')
  2. var version = require('../package.json').version
  3. var themeconfPath = 'themes/uppy/_config.yml'
  4. var configPath = '_config.yml'
  5. var themeconfig = fs.readFileSync(themeconfPath, 'utf-8')
  6. var config = fs.readFileSync(configPath, 'utf-8')
  7. fs.writeFileSync(
  8. themeconfPath,
  9. themeconfig.replace(/uppy_version: .*/, 'uppy_version: ' + version)
  10. )
  11. var sizes = {
  12. min: '../dist/uppy.min.js',
  13. // gz : '../dist/uppy.min.js.gz',
  14. // dev: '../dist/uppy.js'
  15. }
  16. for (var file in sizes) {
  17. var filesize = fs.statSync(sizes[file], 'utf-8').size
  18. sizes[file] = (filesize / 1024).toFixed(2)
  19. }
  20. fs.writeFileSync(
  21. configPath,
  22. config
  23. .replace(/uppy_version: .*/, 'uppy_version: ' + version)
  24. .replace(/uppy_(\w+)_size:.*/g, function (m, p1) {
  25. return 'uppy_' + p1 + '_size: "' + (sizes[p1] || 99999 ) + '"'
  26. })
  27. )