Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: .nojekyll not being staged on build dir files #475

Closed
7 changes: 7 additions & 0 deletions bin/gh-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ function main(args) {
.option('-g, --tag <tag>', 'add tag to commit')
.option('--git <git>', 'Path to git executable', ghpages.defaults.git)
.option('-t, --dotfiles', 'Include dotfiles')
.option('-c, --cname <cname>', 'Include domain for CNAME file')
.option(
'-j, --nojekyll',
'Disable jekyll SSG engine by including a .nojekyll file'
)
.option('-r, --repo <repo>', 'URL of the repository you are pushing to')
.option('-p, --depth <depth>', 'depth for clone', ghpages.defaults.depth)
.option(
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 12 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const log = util.debuglog('gh-pages');
* @return {string} The full path to the cache directory.
*/
function getCacheDir(optPath) {
const dir = findCacheDir({name: 'gh-pages'});
const dir = findCacheDir({ name: 'gh-pages' });

if (!optPath) {
return dir;
}
Expand All @@ -40,6 +41,8 @@ exports.defaults = {
git: 'git',
depth: 1,
dotfiles: false,
cname: undefined,
nojekyll: false,
branch: 'gh-pages',
remote: 'origin',
src: '**/*',
Expand Down Expand Up @@ -97,6 +100,14 @@ exports.publish = function publish(basePath, config, callback) {
return Promise.reject(err);
}

if (options.cname) {
fs.writeFileSync(path.join(basePath, 'CNAME'), options.cname);
}

if (options.nojekyll) {
fs.createFileSync(path.join(basePath, '.nojekyll'));
}

const files = globby
.sync(options.src, {
cwd: basePath,
Expand Down
10 changes: 10 additions & 0 deletions test/bin/gh-pages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down