mirror of
https://github.com/scratchfoundation/gh-pages.git
synced 2024-11-28 10:15:36 -05:00
Explicitly require base path as first parameter
This commit is contained in:
parent
f39a37eeff
commit
f610cf7348
1 changed files with 6 additions and 9 deletions
15
lib/index.js
15
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');
|
||||
|
|
Loading…
Reference in a new issue