diff --git a/lib/index.js b/lib/index.js index cafc02e..2db972f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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'); diff --git a/readme.md b/readme.md index 8662eb3..af77790 100644 --- a/readme.md +++ b/readme.md @@ -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.