vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.2 KiB

  1. // Update the version numbers and library sizes in index.html
  2. var fs = require('fs'),
  3. zlib = require('zlib');
  4. var VIS_ZIP = './dist/vis.js',
  5. INDEX = 'index.html';
  6. // read version from dist/vis.js
  7. function version(callback) {
  8. fs.readFile(VIS_ZIP, function (err, data) {
  9. if (!err) {
  10. var match = /@version\s*([\w\.-]*)/i.exec(data);
  11. var version = undefined;
  12. if (match) {
  13. version = match[1];
  14. }
  15. callback(null, version);
  16. }
  17. else {
  18. callback(err);
  19. }
  20. });
  21. }
  22. // update version and library sizes in index.md
  23. function updateVersion(version, callback) {
  24. fs.readFile(INDEX, function (err, data) {
  25. if (!err) {
  26. data = String(data);
  27. data = data.replace(/<span class="version">([\w\.-]*)<\/span>/g,
  28. '<span class="version">' + version + '</span>');
  29. fs.writeFile(INDEX, data, callback);
  30. }
  31. else {
  32. callback(err);
  33. }
  34. });
  35. }
  36. version(function (err, version) {
  37. console.log('version: ' + version);
  38. if (version) {
  39. updateVersion(version, function (err, res) {
  40. if (err) {
  41. console.log(err);
  42. }
  43. else {
  44. console.log('done');
  45. }
  46. });
  47. }
  48. else {
  49. }
  50. });