update.js 971 B

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