Use rsync instead of copy when preparing files to publish

`shell.cp` does not support dotfiles :(

https://github.com/shelljs/shelljs/issues/79
This commit is contained in:
Joel Marcey 2017-12-12 08:51:29 -08:00
parent 078b379dae
commit b3c44060b9

View file

@ -110,15 +110,18 @@ shell.exec('git rm -rf .');
shell.cd('../..'); shell.cd('../..');
shell.cp( fromPath = path.join('build', PROJECT_PATH, '/');
'-R', toPath = path.join('build', `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`);
// in github.io case, project is deployed to root. need to not recursively // In github.io case, project is deployed to root. Need to not recursively
// copy the deployment-branch to be. // copy the deployment-branch to be.
// The !(...) represents the same thing as "everything but this" excludePath = `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`;
// Copies everything in /build except the directory after the !. // cannot use shell.cp because it doesn't support copying dotfiles and we
path.join('build', PROJECT_PATH, `!(${PROJECT_NAME}-${DEPLOYMENT_BRANCH})`), // need to copy directories like .circleci, for example
path.join('build', `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`) // https://github.com/shelljs/shelljs/issues/79
shell.exec(
`rsync -rtv --exclude=${excludePath} --exclude=.DS_Store ${fromPath} ${toPath}`
); );
shell.cd(path.join('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();