mirror of
https://github.com/scratchfoundation/gh-pages.git
synced 2025-02-26 14:14:06 -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).
|
* 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 = {
|
var defaults = {
|
||||||
add: false,
|
add: false,
|
||||||
git: 'git',
|
git: 'git',
|
||||||
|
@ -59,7 +57,6 @@ exports.publish = function publish(config, done) {
|
||||||
dotfiles: false,
|
dotfiles: false,
|
||||||
branch: 'gh-pages',
|
branch: 'gh-pages',
|
||||||
remote: 'origin',
|
remote: 'origin',
|
||||||
base: process.cwd(),
|
|
||||||
src: '**/*',
|
src: '**/*',
|
||||||
only: '.',
|
only: '.',
|
||||||
push: true,
|
push: true,
|
||||||
|
@ -72,7 +69,7 @@ exports.publish = function publish(config, done) {
|
||||||
var options = _.extend({}, defaults, config);
|
var options = _.extend({}, defaults, config);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!fs.statSync(options.base).isDirectory()) {
|
if (!fs.statSync(basePath).isDirectory()) {
|
||||||
done(new Error('The "base" option must be an existing directory'));
|
done(new Error('The "base" option must be an existing directory'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -82,10 +79,10 @@ exports.publish = function publish(config, done) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var files = glob.sync(options.src, {
|
var files = glob.sync(options.src, {
|
||||||
cwd: options.base,
|
cwd: basePath,
|
||||||
dot: options.dotfiles
|
dot: options.dotfiles
|
||||||
}).filter(function(file) {
|
}).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) {
|
if (!Array.isArray(files) || files.length === 0) {
|
||||||
|
@ -93,7 +90,7 @@ exports.publish = function publish(config, done) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var only = glob.sync(options.only, {cwd: options.base});
|
var only = glob.sync(options.only, {cwd: basePath});
|
||||||
|
|
||||||
function log(message) {
|
function log(message) {
|
||||||
if (!options.silent) {
|
if (!options.silent) {
|
||||||
|
@ -149,7 +146,7 @@ exports.publish = function publish(config, done) {
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
log('Copying files');
|
log('Copying files');
|
||||||
return copy(files, options.base, options.clone);
|
return copy(files, basePath, options.clone);
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
log('Adding all');
|
log('Adding all');
|
||||||
|
|
Loading…
Reference in a new issue