From 2e6e71238b511b14a2afa8fb5ff0e9036c2aea3c Mon Sep 17 00:00:00 2001 From: Sunghwan Bang Date: Wed, 26 Feb 2020 11:27:55 +0900 Subject: [PATCH] Move declaration of removing files. --- lib/index.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/index.js b/lib/index.js index 4338bce2..6736ec42 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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) { @@ -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; }