build-docs.js 941 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env node
  2. "use strict";
  3. const path = require("path");
  4. const shell = require("shelljs");
  5. const rootDir = path.join(__dirname, "..");
  6. const docs = path.join(rootDir, "website/static/lib");
  7. function pipe(string) {
  8. return new shell.ShellString(string);
  9. }
  10. const isPullRequest = process.env.PULL_REQUEST === "true";
  11. const prettierPath = isPullRequest ? "dist" : "node_modules/prettier";
  12. shell.mkdir("-p", docs);
  13. if (isPullRequest) {
  14. // --- Build prettier for PR ---
  15. const pkg = require("../package.json");
  16. pkg.version = `999.999.999-pr.${process.env.REVIEW_ID}`;
  17. pipe(JSON.stringify(pkg, null, 2)).to("package.json");
  18. shell.exec("node scripts/build/build.js");
  19. }
  20. shell.exec(`cp ${prettierPath}/standalone.js ${docs}/`);
  21. shell.exec(`cp ${prettierPath}/parser-*.js ${docs}/`);
  22. // --- Site ---
  23. shell.cd("website");
  24. shell.echo("Building website...");
  25. shell.exec("yarn install");
  26. shell.exec("yarn build");
  27. shell.echo();