build.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* eslint-disable */
  2. var args = process.argv.slice(2);
  3. var fs = require('fs');
  4. var concat = require('concat');
  5. var tmp = require('tmp');
  6. var distDir = './dist/es5';
  7. var distFile = 'jquery.flot.js';
  8. if (!fs.existsSync(distDir)) {
  9. fs.mkdirSync(distDir)
  10. }
  11. function concatenateFiles(destinationPath, callback) {
  12. concat([
  13. './jquery.colorhelpers.js',
  14. './jquery.canvaswrapper.js',
  15. './jquery.flot.js',
  16. './jquery.flot.saturated.js',
  17. './jquery.flot.browser.js',
  18. './jquery.flot.drawSeries.js',
  19. './jquery.flot.uiConstants.js',
  20. './jquery.flot.logaxis.js',
  21. './jquery.flot.symbol.js',
  22. './jquery.flot.flatdata.js',
  23. './jquery.flot.navigate.js',
  24. './jquery.flot.touchNavigate.js',
  25. './jquery.flot.hover.js',
  26. './jquery.flot.touch.js',
  27. './jquery.flot.time.js',
  28. './jquery.flot.axislabels.js',
  29. './jquery.flot.selection.js',
  30. './jquery.flot.composeImages.js',
  31. './jquery.flot.legend.js'
  32. ], destinationPath);
  33. }
  34. if (args[0] === 'test') {
  35. console.log('testing distribution ...');
  36. var tmpobj = tmp.fileSync();
  37. concatenateFiles(tmpobj.name, function(err, result) {
  38. var origBuild = fs.readFileSync(distDir + '/' + distFile, 'utf8');
  39. var newBuild = fs.readFileSync(tmpobj.name, 'utf8');
  40. if (newBuild !== origBuild) {
  41. console.log('The distribution file dist/es5/jquery.flot.js is not up to date. Type "npm run build" to fix it !');
  42. process.exitCode = 1;
  43. return;
  44. }
  45. console.log('Ok');
  46. });
  47. } else {
  48. console.log('building ', distDir + '/' + distFile);
  49. concatenateFiles(distDir + '/' + distFile);
  50. }