Run Prettier

This commit is contained in:
Frank Li 2017-07-10 16:38:35 -07:00
parent a7b5148e06
commit fbae29b0ff
29 changed files with 1311 additions and 987 deletions

View file

@ -9,7 +9,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
const shell = require('shelljs');
const shell = require("shelljs");
const GIT_USER = process.env.GIT_USER;
const CIRCLE_BRANCH = process.env.CIRCLE_BRANCH;
@ -18,54 +18,64 @@ const CIRCLE_PROJECT_REPONAME = process.env.CIRCLE_PROJECT_REPONAME;
const CI_PULL_REQUEST = process.env.CI_PULL_REQUEST;
const remoteBranch = `https://${GIT_USER}@github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git`;
if (!shell.which('git')) {
shell.echo('Sorry, this script requires git');
if (!shell.which("git")) {
shell.echo("Sorry, this script requires git");
shell.exit(1);
}
if (CI_PULL_REQUEST || CIRCLE_BRANCH !== `master`) {
shell.echo('Skipping deploy');
shell.echo("Skipping deploy");
shell.exit(0);
}
if (shell.exec('docusaurus-build').code) {
shell.echo('Error: generating html failed');
if (shell.exec("docusaurus-build").code) {
shell.echo("Error: generating html failed");
shell.exit(1);
}
shell.cd(__dirname);
shell.cd('..');
shell.cd('build');
shell.cd("..");
shell.cd("build");
if (shell.exec(`git clone ${remoteBranch} ${CIRCLE_PROJECT_REPONAME}-gh-pages`).code !== 0) {
shell.echo('Error: git clone failed');
if (
shell.exec(`git clone ${remoteBranch} ${CIRCLE_PROJECT_REPONAME}-gh-pages`)
.code !== 0
) {
shell.echo("Error: git clone failed");
shell.exit(1);
}
shell.cd(`${CIRCLE_PROJECT_REPONAME}-gh-pages`);
if (shell.exec('git checkout origin/gh-pages').code +
shell.exec('git checkout -b gh-pages').code +
shell.exec('git branch --set-upstream-to=origin/gh-pages').code !== 0
) {
shell.echo('Error: Git checkout gh-pages failed');
if (
shell.exec("git checkout origin/gh-pages").code +
shell.exec("git checkout -b gh-pages").code +
shell.exec("git branch --set-upstream-to=origin/gh-pages").code !==
0
) {
shell.echo("Error: Git checkout gh-pages failed");
shell.exit(1);
}
shell.exec('rm -rf *');
shell.exec("rm -rf *");
shell.cd('../..');
shell.cd("../..");
shell.cp('-R', `build/${CIRCLE_PROJECT_REPONAME}/*`, `build/${CIRCLE_PROJECT_REPONAME}-gh-pages/`);
shell.cp(
"-R",
`build/${CIRCLE_PROJECT_REPONAME}/*`,
`build/${CIRCLE_PROJECT_REPONAME}-gh-pages/`
);
shell.cd(`build/${CIRCLE_PROJECT_REPONAME}-gh-pages`);
shell.exec('git add --all');
shell.exec("git add --all");
shell.exec('git commit -m "update website [ci skip]"');
if (shell.exec('git push origin gh-pages').code !== 0) {
shell.echo('Error: Git push failed');
if (shell.exec("git push origin gh-pages").code !== 0) {
shell.echo("Error: Git push failed");
shell.exit(1);
} else {
shell.echo(`Website is live at: https://${CIRCLE_PROJECT_USERNAME}.github.io/${CIRCLE_PROJECT_REPONAME}/`);
shell.echo(
`Website is live at: https://${CIRCLE_PROJECT_USERNAME}.github.io/${CIRCLE_PROJECT_REPONAME}/`
);
shell.exit(0);
}