Skip to content

Commit 0b3f02c

Browse files
committed
Use default for git
1 parent ba7e5e1 commit 0b3f02c

File tree

3 files changed

+34
-38
lines changed

3 files changed

+34
-38
lines changed

bin/gh-pages.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,35 @@ function main(args) {
2626
.option(
2727
'-s, --src <src>',
2828
'Pattern used to select which files to publish',
29-
'**/*'
29+
ghpages.defaults.src
3030
)
3131
.option(
3232
'-b, --branch <branch>',
3333
'Name of the branch you are pushing to',
34-
'gh-pages'
34+
ghpages.defaults.branch
3535
)
3636
.option(
3737
'-e, --dest <dest>',
3838
'Target directory within the destination branch (relative to the root)',
39-
'.'
39+
ghpages.defaults.dest
4040
)
4141
.option('-a, --add', 'Only add, and never remove existing files')
4242
.option('-x, --silent', 'Do not output the repository url')
43-
.option('-m, --message <message>', 'commit message', 'Updates')
43+
.option(
44+
'-m, --message <message>',
45+
'commit message',
46+
ghpages.defaults.message
47+
)
4448
.option('-g, --tag <tag>', 'add tag to commit')
45-
.option('--git <git>', 'Path to git executable')
49+
.option('--git <git>', 'Path to git executable', ghpages.defaults.git)
4650
.option('-t, --dotfiles', 'Include dotfiles')
4751
.option('-r, --repo <repo>', 'URL of the repository you are pushing to')
48-
.option('-p, --depth <depth>', 'depth for clone', 1)
49-
.option('-o, --remote <name>', 'The name of the remote', 'origin')
52+
.option('-p, --depth <depth>', 'depth for clone', ghpages.defaults.depth)
53+
.option(
54+
'-o, --remote <name>',
55+
'The name of the remote',
56+
ghpages.defaults.remote
57+
)
5058
.option(
5159
'-u, --user <address>',
5260
'The name and email of the user (defaults to the git config). Format is "Your Name <[email protected]>".'
@@ -55,7 +63,7 @@ function main(args) {
5563
'-v, --remove <pattern>',
5664
'Remove files that match the given pattern ' +
5765
'(ignored if used together with --add).',
58-
'.'
66+
ghpages.defaults.only
5967
)
6068
.option('-n, --no-push', 'Commit only (with no push)')
6169
.parse(args);
@@ -81,6 +89,7 @@ function main(args) {
8189
message: program.message,
8290
tag: program.tag,
8391
git: program.git,
92+
depth: program.depth,
8493
dotfiles: !!program.dotfiles,
8594
add: !!program.add,
8695
only: program.remove,

lib/index.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ function getRepo(options) {
2222
}
2323
}
2424

25+
exports.defaults = {
26+
dest: '.',
27+
add: false,
28+
git: 'git',
29+
depth: 1,
30+
dotfiles: false,
31+
branch: 'gh-pages',
32+
remote: 'origin',
33+
src: '**/*',
34+
only: '.',
35+
push: true,
36+
message: 'Updates',
37+
silent: false
38+
};
39+
2540
/**
2641
* Push a git branch to a remote (pushes gh-pages by default).
2742
* @param {string} basePath The base path.
@@ -34,22 +49,7 @@ exports.publish = function publish(basePath, config, callback) {
3449
config = {};
3550
}
3651

37-
const defaults = {
38-
dest: '.',
39-
add: false,
40-
git: 'git',
41-
depth: 1,
42-
dotfiles: false,
43-
branch: 'gh-pages',
44-
remote: 'origin',
45-
src: '**/*',
46-
only: '.',
47-
push: true,
48-
message: 'Updates',
49-
silent: false
50-
};
51-
52-
const options = Object.assign({}, defaults, config);
52+
const options = Object.assign({}, exports.defaults, config);
5353

5454
if (!callback) {
5555
callback = function(err) {

test/bin/gh-pages.spec.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,11 @@ describe('gh-pages', () => {
1515
ghpages.publish.restore();
1616
});
1717

18-
const defaults = {
19-
repo: undefined,
20-
silent: false,
21-
branch: 'gh-pages',
22-
src: '**/*',
23-
dest: '.',
24-
message: 'Updates',
25-
dotfiles: false,
26-
add: false,
27-
remote: 'origin',
28-
push: true
29-
};
30-
3118
const scenarios = [
3219
{
3320
args: ['--dist', 'lib'],
3421
dist: 'lib',
35-
config: defaults
22+
config: ghpages.defaults
3623
},
3724
{
3825
args: ['--dist', 'lib', '-n'],

0 commit comments

Comments
 (0)