buildDocs.js 588 B

123456789101112131415161718192021
  1. const { exec } = require("child_process");
  2. // get files changed between prev and head commit
  3. exec(`git diff --name-only HEAD^ HEAD`, async (error, stdout, stderr) => {
  4. if (error || stderr) {
  5. console.error(error);
  6. process.exit(1);
  7. }
  8. const changedFiles = stdout.trim().split("\n");
  9. const docFiles = changedFiles.filter((file) => {
  10. return file.indexOf("docs") >= 0;
  11. });
  12. if (!docFiles.length) {
  13. console.info("Skipping building docs as no valid diff found");
  14. process.exit(0);
  15. }
  16. // Exit code 1 to build the docs in ignoredBuildStep
  17. process.exit(1);
  18. });