Skip to content

Commit

Permalink
Move declaration of removing files.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunghwan2789 committed Feb 26, 2020
1 parent 0d52b35 commit 2e6e712
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ exports.publish = function publish(basePath, config, callback) {
return;
}

const only = globby.sync(options.only, {cwd: basePath}).map(file => {
return path.join(options.dest, file);
});

let repoUrl;
let userPromise;
if (options.user) {
Expand Down Expand Up @@ -151,9 +147,18 @@ exports.publish = function publish(basePath, config, callback) {
}
})
.then(git => {
if (!options.add && only.length > 0) {
if (!options.add) {
log('Removing files');
return git.rm(only.join(' '));
const only = globby
.sync(options.only, { cwd: basePath })
.map(file => {
return path.join(options.dest, file);
});
if (only.length > 0) {
return git.rm(only.join(' '));
} else {
return git;
}
} else {
return git;
}
Expand Down

0 comments on commit 2e6e712

Please sign in to comment.