integrated changes from lelandmiller:base-dir

This commit is contained in:
Jan-Felix 2017-04-04 15:53:54 +02:00
parent e0f90a8ec2
commit fde7245554
2 changed files with 24 additions and 2 deletions

View file

@ -57,6 +57,7 @@ exports.publish = function publish(basePath, config, callback) {
}
var defaults = {
dest: '.',
add: false,
git: 'git',
clone: getCacheDir(),
@ -168,14 +169,17 @@ exports.publish = function publish(basePath, config, callback) {
.then(function() {
if (!options.add) {
log('Removing files');
return git.rm(only.join(' '), options.clone);
var outputFiles = only.map(function(file) {
return path.join(options.dest, file);
});
return git.rm(outputFiles.join(' '), options.clone);
} else {
return Q.resolve();
}
})
.then(function() {
log('Copying files');
return copy(files, basePath, options.clone);
return copy(files, basePath, path.join(options.clone, options.dest));
})
.then(function() {
log('Adding all');

View file

@ -299,6 +299,24 @@ ghpages.publish(path.join(__dirname, 'build'), {
}, callback);
```
#### <a id="optionsdest">options.dest</a>
* type: `string`
* default: `'.'`
The destination folder within the destination branch/repository.
Example use of the `dest` option:
```js
/**
* Place content in the static/project subdirectory of the target
* branch/repository. If removing files, only remove static/project.
*/
ghpages.publish(path.join(__dirname, 'build'), {
dest: 'static/project'
}, callback);
```
## Command Line Utility
Installing the package creates a `gh-pages` command line utility. Run `gh-pages --help` to see a list of supported options.