mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-09 21:07:55 +02:00
Switch rsync for fs-extra (#321)
This commit is contained in:
parent
54ffbddcd8
commit
eafcf13a4c
3 changed files with 29 additions and 28 deletions
|
@ -7,8 +7,8 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const Rsync = require('rsync');
|
||||
const shell = require('shelljs');
|
||||
|
||||
if (!shell.which('git')) {
|
||||
|
@ -114,23 +114,29 @@ 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.
|
||||
excludePath = `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`;
|
||||
|
||||
// cannot use shell.cp because it doesn't support copying dotfiles and we
|
||||
// need to copy directories like .circleci, for example
|
||||
// https://github.com/shelljs/shelljs/issues/79
|
||||
const rsync = new Rsync()
|
||||
.flags('rt')
|
||||
.exclude(excludePath)
|
||||
.exclude('.DS_Store')
|
||||
.source(fromPath)
|
||||
.destination(toPath);
|
||||
fs.copy(
|
||||
fromPath,
|
||||
toPath,
|
||||
(src, dest) => {
|
||||
if (src.indexOf('.DS_Store') !== -1) {
|
||||
return false;
|
||||
}
|
||||
if (src.indexOf(excludePath) !== -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
error => {
|
||||
if (error) {
|
||||
shell.echo(`Error: Copying build assets failed with error '${error}'`);
|
||||
shell.exit(1);
|
||||
}
|
||||
|
||||
rsync.execute((error, code, cmd) => {
|
||||
if (code !== 0) {
|
||||
shell.echo(
|
||||
`Error: Copying build assets failed with code ${code} and error '${error}'`
|
||||
);
|
||||
shell.exit(1);
|
||||
} else {
|
||||
shell.cd(path.join('build', `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`));
|
||||
|
||||
const currentCommit = shell.exec('git rev-parse HEAD').stdout.trim();
|
||||
|
@ -151,4 +157,4 @@ rsync.execute((error, code, cmd) => {
|
|||
shell.exit(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue