Skip to content

Commit

Permalink
fix: Handle parent directory as destination (#69)
Browse files Browse the repository at this point in the history
I'm open to the suggestion that I'm just doing this wrong :), but: 

The project I'm working with has multiple submodules. One of these modules (two subdirectories deep) we would like to publish with this tool to the gh-pages branch, but to the top-level directory on the gh-pages branch.

E.g.: 
```
ember github-pages:commit --message "Update gh-pages release" --destination ../../
```

This fails in two places: 
* rm -rf ../.. is problematic; 
* mkdir ../.. complains that it's creating a directory that already exists

To fix this I've added a regex that allows this case to be handled by the first condition of the branch.
  • Loading branch information
jacobtolar authored and knownasilya committed Apr 27, 2019
1 parent 78457da commit 6c7b365
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/commands/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var exec = require('child_process').exec;
var RSVP = require('rsvp');
var path = require('path');

module.exports = {
name: 'github-pages:commit',
Expand Down Expand Up @@ -46,8 +47,9 @@ module.exports = {
}

function copy() {
if (options.destination === '.') {
return runCommand('cp -R dist/* .', execOptions);
var rel = path.relative(root, options.destination);
if (options.destination === '.' || rel.match(/^\.\.(\/\.\.)*$/)) {
return runCommand('cp -R dist/* ' + options.destination + '/', execOptions);
} else {
return runCommand('rm -r ' + options.destination, execOptions)
.then(function() {
Expand Down

0 comments on commit 6c7b365

Please sign in to comment.