mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-03 12:17:20 +02:00
Always use PROJECT_NAME, even for user and org pages (#384)
* Always use PROJECT_NAME, even for user and org pages The symptom was that if we had a user or org page (e.g., https://JoelMarcey.github.io), we would try to copy files to a directory within a directory, getting errors like: ``` Error: Copying build assets failed with error 'Error: Cannot copy '/Users/joelm/dev/JoelMarcey.github.io/website/build' to a subdirectory of itself, '/Users/joelm/dev/JoelMarcey.github.io/website/build/JoelMarcey.github.io-master'.' ``` This is because we were setting the end of `fromPath` to empty if we were using an org or user page. But we don't need to do that. The `PROJECT_NAME` (set in `siteConfig.js` as `projectName`) is the user or org repo e.g., https://github.com/JoelMarcey/JoelMarcey.github.io/ has a `projectName` of `JoelMarcey.github.io` with an `organizationName` of `JoelMarcey`. So now the `fromPath` and `toPath` look like: `fromPath`: `build/JoelMarcey.github.io` `toPath`: `buuid/JoelMarcey.github.io-master`
This commit is contained in:
parent
654916ae98
commit
c14a8d2e77
1 changed files with 2 additions and 4 deletions
|
@ -34,8 +34,6 @@ const USE_SSH = process.env.USE_SSH;
|
|||
// github.io indicates organization repos that deploy via master. All others use gh-pages.
|
||||
const DEPLOYMENT_BRANCH =
|
||||
PROJECT_NAME.indexOf('.github.io') !== -1 ? 'master' : 'gh-pages';
|
||||
const PROJECT_PATH =
|
||||
PROJECT_NAME.indexOf('.github.io') !== -1 ? '' : PROJECT_NAME;
|
||||
|
||||
if (!ORGANIZATION_NAME) {
|
||||
shell.echo(
|
||||
|
@ -109,7 +107,7 @@ shell.exec('git rm -rf .');
|
|||
|
||||
shell.cd('../..');
|
||||
|
||||
fromPath = path.join('build', PROJECT_PATH, '/');
|
||||
fromPath = path.join('build', `${PROJECT_NAME}`);
|
||||
toPath = path.join('build', `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`);
|
||||
// In github.io case, project is deployed to root. Need to not recursively
|
||||
// copy the deployment-branch to be.
|
||||
|
@ -152,7 +150,7 @@ fs.copy(
|
|||
} else if (commitResults.code === 0) {
|
||||
// The commit might return a non-zero value when site is up to date.
|
||||
shell.echo(
|
||||
`Website is live at: https://${ORGANIZATION_NAME}.github.io/${PROJECT_PATH}`
|
||||
`Website is live at: https://${ORGANIZATION_NAME}.github.io/${PROJECT_NAME}`
|
||||
);
|
||||
shell.exit(0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue