mirror of
https://github.com/rschamp/gh-pages.git
synced 2025-11-04 21:01:11 +08:00
better error handling, fix #20
- provide error handling for callback - provide default error handling if no callback is passed
This commit is contained in:
parent
1447396597
commit
b6eb464991
19
lib/index.js
19
lib/index.js
@ -48,14 +48,27 @@ function getRepo(options) {
|
|||||||
* Push a git branch to a remote (pushes gh-pages by default).
|
* Push a git branch to a remote (pushes gh-pages by default).
|
||||||
* @param {string} basePath The base path.
|
* @param {string} basePath The base path.
|
||||||
* @param {Object} config Publish options.
|
* @param {Object} config Publish options.
|
||||||
* @param {Function} done Callback.
|
* @param {Function} callback Callback.
|
||||||
*/
|
*/
|
||||||
exports.publish = function publish(basePath, config, done) {
|
/*eslint-disable no-console */
|
||||||
|
exports.publish = function publish(basePath, config, callback) {
|
||||||
if (typeof config === 'function') {
|
if (typeof config === 'function') {
|
||||||
done = config;
|
callback = config;
|
||||||
config = {};
|
config = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var done = function(arguments) {
|
||||||
|
try {
|
||||||
|
(callback || function(err) {
|
||||||
|
if (!err) {
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
|
})(arguments);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('errors during calling the callback: ', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
add: false,
|
add: false,
|
||||||
git: 'git',
|
git: 'git',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user