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

config: include --nojekyll option flag #468

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 11 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const log = util.debuglog('gh-pages');
*/
function getCacheDir(optPath) {
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 @@ -113,6 +116,14 @@ exports.publish = function publish(basePath, config, callback) {
return;
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will result in the CNAME file being written to the dest directory (which may be a subdirectory not at the root of the repo). I think it should be written to the root instead.


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same above as above about writing to the dest directory instead of the root. In addition, won't this file be ignored unless the --dotfiles option is also specified?


let repoUrl;
let userPromise;
if (options.user) {
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