From d7bb3613f910830846415589b3ed6809677e4c34 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 8 Aug 2019 07:29:50 -0600 Subject: [PATCH] Use default for git --- bin/gh-pages.js | 24 ++++++++++++++++-------- lib/index.js | 32 ++++++++++++++++---------------- test/bin/gh-pages.spec.js | 3 ++- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/bin/gh-pages.js b/bin/gh-pages.js index c2b9e84b..014dea61 100755 --- a/bin/gh-pages.js +++ b/bin/gh-pages.js @@ -26,27 +26,35 @@ function main(args) { .option( '-s, --src ', 'Pattern used to select which files to publish', - '**/*' + ghpages.defaults.src ) .option( '-b, --branch ', 'Name of the branch you are pushing to', - 'gh-pages' + ghpages.defaults.branch ) .option( '-e, --dest ', 'Target directory within the destination branch (relative to the root)', - '.' + ghpages.defaults.dest ) .option('-a, --add', 'Only add, and never remove existing files') .option('-x, --silent', 'Do not output the repository url') - .option('-m, --message ', 'commit message', 'Updates') + .option( + '-m, --message ', + 'commit message', + ghpages.defaults.message + ) .option('-g, --tag ', 'add tag to commit') - .option('--git ', 'Path to git executable') + .option('--git ', 'Path to git executable', ghpages.defaults.git) .option('-t, --dotfiles', 'Include dotfiles') .option('-r, --repo ', 'URL of the repository you are pushing to') - .option('-p, --depth ', 'depth for clone', 1) - .option('-o, --remote ', 'The name of the remote', 'origin') + .option('-p, --depth ', 'depth for clone', ghpages.defaults.depth) + .option( + '-o, --remote ', + 'The name of the remote', + ghpages.defaults.remote + ) .option( '-u, --user
', 'The name and email of the user (defaults to the git config). Format is "Your Name ".' @@ -55,7 +63,7 @@ function main(args) { '-v, --remove ', 'Remove files that match the given pattern ' + '(ignored if used together with --add).', - '.' + ghpages.defaults.only ) .option('-n, --no-push', 'Commit only (with no push)') .parse(args); diff --git a/lib/index.js b/lib/index.js index 1656a7a4..248aa05e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -22,6 +22,21 @@ function getRepo(options) { } } +exports.defaults = { + dest: '.', + add: false, + git: 'git', + depth: 1, + dotfiles: false, + branch: 'gh-pages', + remote: 'origin', + src: '**/*', + only: '.', + push: true, + message: 'Updates', + silent: false +}; + /** * Push a git branch to a remote (pushes gh-pages by default). * @param {string} basePath The base path. @@ -34,22 +49,7 @@ exports.publish = function publish(basePath, config, callback) { config = {}; } - const defaults = { - dest: '.', - add: false, - git: 'git', - depth: 1, - dotfiles: false, - branch: 'gh-pages', - remote: 'origin', - src: '**/*', - only: '.', - push: true, - message: 'Updates', - silent: false - }; - - const options = Object.assign({}, defaults, config); + const options = Object.assign({}, exports.defaults, config); if (!callback) { callback = function(err) { diff --git a/test/bin/gh-pages.spec.js b/test/bin/gh-pages.spec.js index 10a236f6..090622e5 100644 --- a/test/bin/gh-pages.spec.js +++ b/test/bin/gh-pages.spec.js @@ -25,7 +25,8 @@ describe('gh-pages', () => { dotfiles: false, add: false, remote: 'origin', - push: true + push: true, + git: 'git' }; const scenarios = [