mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-02 11:47:23 +02:00
allow copy from /build in github.io case (#260)
* allow copy from /build in github.io case * Comment explaining the ! in the path.join
This commit is contained in:
parent
97612cf20b
commit
8074b96c79
1 changed files with 13 additions and 8 deletions
|
@ -8,6 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const shell = require('shelljs');
|
const shell = require('shelljs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
if (!shell.which('git')) {
|
if (!shell.which('git')) {
|
||||||
shell.echo('Sorry, this script requires git');
|
shell.echo('Sorry, this script requires git');
|
||||||
|
@ -32,6 +33,8 @@ const USE_SSH = process.env.USE_SSH;
|
||||||
// github.io indicates organization repos that deploy via master. All others use gh-pages.
|
// github.io indicates organization repos that deploy via master. All others use gh-pages.
|
||||||
const DEPLOYMENT_BRANCH =
|
const DEPLOYMENT_BRANCH =
|
||||||
PROJECT_NAME.indexOf('.github.io') !== -1 ? 'master' : 'gh-pages';
|
PROJECT_NAME.indexOf('.github.io') !== -1 ? 'master' : 'gh-pages';
|
||||||
|
const PROJECT_PATH =
|
||||||
|
PROJECT_NAME.indexOf('.github.io') !== -1 ? '' : PROJECT_NAME;
|
||||||
|
|
||||||
if (!ORGANIZATION_NAME) {
|
if (!ORGANIZATION_NAME) {
|
||||||
shell.echo(
|
shell.echo(
|
||||||
|
@ -68,7 +71,7 @@ if (CURRENT_BRANCH === DEPLOYMENT_BRANCH) {
|
||||||
shell.exit(1);
|
shell.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shell.exec(`node ${__dirname}/build-files.js`).code) {
|
if (shell.exec(`node ${path.join(__dirname, "build-files.js")}`).code) {
|
||||||
shell.echo('Error: generating html failed');
|
shell.echo('Error: generating html failed');
|
||||||
shell.exit(1);
|
shell.exit(1);
|
||||||
}
|
}
|
||||||
|
@ -108,11 +111,15 @@ shell.exec('git rm -rf .');
|
||||||
shell.cd('../..');
|
shell.cd('../..');
|
||||||
|
|
||||||
shell.cp(
|
shell.cp(
|
||||||
'-R',
|
"-R",
|
||||||
`build/${PROJECT_NAME}/*`,
|
// in github.io case, project is deployed to root. need to not recursively
|
||||||
`build/${PROJECT_NAME}-${DEPLOYMENT_BRANCH}/`
|
// copy the deployment-branch to be.
|
||||||
|
// The !(...) represents the same thing as "everything but this"
|
||||||
|
// Copies everything in /build except the directory after the !.
|
||||||
|
path.join("build", PROJECT_PATH, `!(${PROJECT_NAME}-${DEPLOYMENT_BRANCH})`),
|
||||||
|
path.join("build", `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`)
|
||||||
);
|
);
|
||||||
shell.cd(`build/${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`);
|
shell.cd(path.join("build", `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`));
|
||||||
|
|
||||||
const currentCommit = shell.exec('git rev-parse HEAD').stdout.trim();
|
const currentCommit = shell.exec('git rev-parse HEAD').stdout.trim();
|
||||||
|
|
||||||
|
@ -128,9 +135,7 @@ if (shell.exec(`git push origin ${DEPLOYMENT_BRANCH}`).code !== 0) {
|
||||||
shell.exit(1);
|
shell.exit(1);
|
||||||
} else {
|
} else {
|
||||||
shell.echo(
|
shell.echo(
|
||||||
`Website is live at: https://${ORGANIZATION_NAME}.github.io/${
|
`Website is live at: https://${ORGANIZATION_NAME}.github.io/${PROJECT_PATH}`
|
||||||
PROJECT_NAME
|
|
||||||
}/`
|
|
||||||
);
|
);
|
||||||
shell.exit(0);
|
shell.exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue