2018-05-27 21:14:01 +03:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const path = require("path");
|
|
|
|
const shell = require("shelljs");
|
|
|
|
|
2018-08-07 13:53:11 +03:00
|
|
|
shell.config.fatal = true;
|
|
|
|
|
2018-05-27 21:31:52 +03:00
|
|
|
const rootDir = path.join(__dirname, "..");
|
2018-05-27 21:14:01 +03:00
|
|
|
const docs = path.join(rootDir, "website/static/lib");
|
|
|
|
|
|
|
|
function pipe(string) {
|
|
|
|
return new shell.ShellString(string);
|
|
|
|
}
|
|
|
|
|
|
|
|
const isPullRequest = process.env.PULL_REQUEST === "true";
|
|
|
|
const prettierPath = isPullRequest ? "dist" : "node_modules/prettier";
|
|
|
|
|
|
|
|
shell.mkdir("-p", docs);
|
|
|
|
|
|
|
|
if (isPullRequest) {
|
|
|
|
// --- Build prettier for PR ---
|
2018-05-28 03:51:50 +03:00
|
|
|
const pkg = require("../package.json");
|
2018-12-25 03:20:35 +03:00
|
|
|
const newPkg = Object.assign({}, pkg, {
|
|
|
|
version: `999.999.999-pr.${process.env.REVIEW_ID}`
|
|
|
|
});
|
|
|
|
pipe(JSON.stringify(newPkg, null, 2)).to("package.json");
|
2018-08-07 13:53:11 +03:00
|
|
|
shell.exec("yarn build");
|
2018-12-25 03:20:35 +03:00
|
|
|
pipe(JSON.stringify(pkg, null, 2)).to("package.json"); // restore
|
2018-05-27 21:14:01 +03:00
|
|
|
}
|
2019-01-11 02:33:43 +03:00
|
|
|
shell.cp(`${prettierPath}/standalone.js`, `${docs}/`);
|
|
|
|
shell.cp(`${prettierPath}/parser-*.js`, `${docs}/`);
|
2018-05-27 21:14:01 +03:00
|
|
|
|
|
|
|
// --- Site ---
|
|
|
|
shell.cd("website");
|
|
|
|
shell.echo("Building website...");
|
|
|
|
shell.exec("yarn install");
|
|
|
|
|
|
|
|
shell.exec("yarn build");
|
|
|
|
|
|
|
|
shell.echo();
|