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:
Joel Marcey 2018-01-09 09:11:07 -08:00 committed by GitHub
parent 654916ae98
commit c14a8d2e77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}