diff --git a/bin/gh-pages.js b/bin/gh-pages.js index 98fb8ec4..05edb7b1 100755 --- a/bin/gh-pages.js +++ b/bin/gh-pages.js @@ -48,6 +48,11 @@ function main(args) { .option('-g, --tag ', 'add tag to commit') .option('--git ', 'Path to git executable', ghpages.defaults.git) .option('-t, --dotfiles', 'Include dotfiles') + .option('-c, --cname ', 'Include domain for CNAME file') + .option( + '-j, --nojekyll', + 'Disable jekyll SSG engine by including a .nojekyll file' + ) .option('-r, --repo ', 'URL of the repository you are pushing to') .option('-p, --depth ', 'depth for clone', ghpages.defaults.depth) .option( @@ -116,6 +121,8 @@ function main(args) { git: program.git, depth: program.depth, dotfiles: !!program.dotfiles, + cname: program.cname, + nojekyll: !!program.nojekyll, add: !!program.add, remove: program.remove, remote: program.remote, diff --git a/lib/index.js b/lib/index.js index 42613de7..7cc32a29 100644 --- a/lib/index.js +++ b/lib/index.js @@ -17,6 +17,7 @@ const log = util.debuglog('gh-pages'); */ function getCacheDir(optPath) { const dir = findCacheDir({name: 'gh-pages'}); + if (!optPath) { return dir; } @@ -40,6 +41,8 @@ exports.defaults = { git: 'git', depth: 1, dotfiles: false, + cname: undefined, + nojekyll: false, branch: 'gh-pages', remote: 'origin', src: '**/*', @@ -113,6 +116,14 @@ exports.publish = function publish(basePath, config, callback) { return; } + if (options.cname) { + fs.writeFileSync(path.join(basePath, 'CNAME'), options.cname); + } + + if (options.nojekyll) { + fs.createFileSync(path.join(basePath, '.nojekyll')); + } + let repoUrl; let userPromise; if (options.user) { diff --git a/test/bin/gh-pages.spec.js b/test/bin/gh-pages.spec.js index af4d6e48..e1062bd2 100644 --- a/test/bin/gh-pages.spec.js +++ b/test/bin/gh-pages.spec.js @@ -42,6 +42,16 @@ describe('gh-pages', () => { dist: 'lib', config: {dotfiles: true}, }, + { + args: ['--dist', 'lib', '--cname', 'cool.domain'], + dist: 'lib', + config: {cname: 'cool.domain'}, + }, + { + args: ['--dist', 'lib', '--nojekyll'], + dist: 'lib', + config: {nojekyll: true}, + }, { args: ['--dist', 'lib', '--dest', 'target'], dist: 'lib',