diff --git a/lib/index.js b/lib/index.js index 94ab765..c01d721 100644 --- a/lib/index.js +++ b/lib/index.js @@ -48,10 +48,8 @@ function getRepo(options) { /** * Push a git branch to a remote (pushes gh-pages by default). - * @param {Object} config Publish options. - * @param {function(Error)} done Called upon completion. */ -exports.publish = function publish(config, done) { +exports.publish = function publish(basePath, config, done) { var defaults = { add: false, git: 'git', @@ -59,7 +57,6 @@ exports.publish = function publish(config, done) { dotfiles: false, branch: 'gh-pages', remote: 'origin', - base: process.cwd(), src: '**/*', only: '.', push: true, @@ -72,7 +69,7 @@ exports.publish = function publish(config, done) { var options = _.extend({}, defaults, config); try { - if (!fs.statSync(options.base).isDirectory()) { + if (!fs.statSync(basePath).isDirectory()) { done(new Error('The "base" option must be an existing directory')); return; } @@ -82,10 +79,10 @@ exports.publish = function publish(config, done) { } var files = glob.sync(options.src, { - cwd: options.base, + cwd: basePath, dot: options.dotfiles }).filter(function(file) { - return !fs.statSync(path.join(options.base, file)).isDirectory(); + return !fs.statSync(path.join(basePath, file)).isDirectory(); }); if (!Array.isArray(files) || files.length === 0) { @@ -93,7 +90,7 @@ exports.publish = function publish(config, done) { return; } - var only = glob.sync(options.only, {cwd: options.base}); + var only = glob.sync(options.only, {cwd: basePath}); function log(message) { if (!options.silent) { @@ -149,7 +146,7 @@ exports.publish = function publish(config, done) { }) .then(function() { log('Copying files'); - return copy(files, options.base, options.clone); + return copy(files, basePath, options.clone); }) .then(function() { log('Adding all');