mirror of
https://github.com/scratchfoundation/gh-pages.git
synced 2024-11-28 18:25:38 -05:00
Merge pull request #61 from tschaub/custom-remote
Support a custom remote.
This commit is contained in:
commit
06238afaa6
4 changed files with 28 additions and 6 deletions
|
@ -15,6 +15,8 @@ program
|
|||
.option('-x, --silent', 'Do not output the repository url')
|
||||
.option('-b, --branch <branch>',
|
||||
'name of the branch you\'ll be pushing to', 'gh-pages')
|
||||
.option('-o, --remote <name>',
|
||||
'The name of the remote', 'origin')
|
||||
.option('-m, --message <message>',
|
||||
'commit message', 'Updates')
|
||||
.option('-t, --dotfiles', 'Include dotfiles')
|
||||
|
@ -30,6 +32,7 @@ ghpages.publish(path.join(process.cwd(), program.dist), {
|
|||
message: program.message,
|
||||
dotfiles: !!program.dotfiles,
|
||||
add: !!program.add,
|
||||
remote: program.remote,
|
||||
push: !program.noPush,
|
||||
logger: function(message) {
|
||||
process.stderr.write(message + '\n');
|
||||
|
|
|
@ -99,13 +99,14 @@ exports.clone = function clone(repo, dir, branch, options) {
|
|||
return Q.resolve();
|
||||
} else {
|
||||
return fs.makeTree(path.dirname(path.resolve(dir))).then(function() {
|
||||
var args = ['clone', repo, dir, '--branch', branch, '--single-branch'];
|
||||
var args = ['clone', repo, dir, '--branch', branch, '--single-branch',
|
||||
'--origin', options.remote];
|
||||
if (options.depth) {
|
||||
args.push('--depth', options.depth);
|
||||
}
|
||||
return spawn(git, args).fail(function(err) {
|
||||
// try again without banch options
|
||||
return spawn(git, ['clone', repo, dir]);
|
||||
return spawn(git, ['clone', repo, dir, '--origin', options.remote]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@ function getRemoteUrl(dir, remote) {
|
|||
})
|
||||
.fail(function(err) {
|
||||
return Q.reject(new Error(
|
||||
'Failed to get remote.origin.url (task must either be run in a ' +
|
||||
'git repository with a configured origin remote or must be ' +
|
||||
'configured with the "repo" option).'));
|
||||
'Failed to get remote.' + remote + '.url (task must either be ' +
|
||||
'run in a git repository with a configured ' + remote + ' remote ' +
|
||||
'or must be configured with the "repo" option).'));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ function getRepo(options) {
|
|||
if (options.repo) {
|
||||
return Q.resolve(options.repo);
|
||||
} else {
|
||||
return getRemoteUrl(process.cwd(), 'origin');
|
||||
return getRemoteUrl(process.cwd(), options.remote);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
18
readme.md
18
readme.md
|
@ -149,6 +149,24 @@ ghpages.publish(path.join(__dirname, 'build'), {
|
|||
```
|
||||
|
||||
|
||||
#### <a id="optionsremote">options.remote</a>
|
||||
* type: `string`
|
||||
* default: `'origin'`
|
||||
|
||||
The name of the remote you'll be pushing to. The default is your `'origin'` remote, but this can be configured to push to any remote.
|
||||
|
||||
Example use of the `remote` option:
|
||||
|
||||
```js
|
||||
/**
|
||||
* This task pushes to the `gh-pages` branch of of your `upstream` remote.
|
||||
*/
|
||||
ghpages.publish(path.join(__dirname, 'build'), {
|
||||
remote: 'upstream'
|
||||
}, callback);
|
||||
```
|
||||
|
||||
|
||||
#### <a id="optionstag">options.tag</a>
|
||||
* type: `string`
|
||||
* default: `''`
|
||||
|
|
Loading…
Reference in a new issue