gulpTasks-whatsNew.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Import Dependencies.
  2. var gulp = require("gulp");
  3. var fs = require("fs");
  4. /**
  5. * Tests the whats new file to ensure changes have been made in the PR.
  6. */
  7. gulp.task("tests-whatsnew", function(done) {
  8. // Check status on azure
  9. if (!process.env["AZURE_PULLREQUESTID"]) {
  10. // Only checks on Travis
  11. if (!process.env.TRAVIS) {
  12. done();
  13. return;
  14. }
  15. // Only checks on Pull Requests
  16. if (process.env.TRAVIS_PULL_REQUEST == "false") {
  17. done();
  18. return;
  19. }
  20. // Do not check deploy
  21. if (process.env.TRAVIS_BRANCH == "preview") {
  22. done();
  23. return;
  24. }
  25. }
  26. // Compare what's new with the current one in the preview release folder.
  27. const https = require("https");
  28. const url = "https://rawgit.com/BabylonJS/Babylon.js/master/dist/preview%20release/what's%20new.md";
  29. https.get(url, res => {
  30. res.setEncoding("utf8");
  31. let oldData = "";
  32. res.on("data", data => {
  33. oldData += data;
  34. });
  35. res.on("end", () => {
  36. fs.readFile("../../dist/preview release/what's new.md", "utf-8", function(err, newData) {
  37. console.log(newData)
  38. if (err || oldData != newData) {
  39. done();
  40. return;
  41. }
  42. console.error("What's new file did not change.");
  43. process.exit(1);
  44. });
  45. });
  46. });
  47. });