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

Enable gh-pages "beforeAdd" support #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions bin/deploy-to-github-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async function main() {
.option('-m, --defaultBranch [defaultBranch]', 'Specify the default branch for your repo')
.option('--dotfiles', 'Include dotfiles')
.option('--verbose', 'Log verbose information from gh-pages')
.option('--before-add [before-add]', 'Before add gh-pages option')
.parse(process.argv);

const options = cleanOptions({
Expand All @@ -28,6 +29,7 @@ async function main() {
defaultBranch: program.defaultBranch,
dotfiles: !!program.dotfiles,
verbose: !!program.verbose,
beforeAdd: program.beforeAdd,
});

try {
Expand Down
3 changes: 2 additions & 1 deletion lib/deployment/pages/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ async function deployDirectoryToGithubPages(directory, options) {
}
}

function deploy(directory, { token, owner, repo, verbose, dotfiles }) {
function deploy(directory, { token, owner, repo, verbose, dotfiles, beforeAdd }) {
const params = {
add: true,
repo: `https://${token}@github.com/${owner}/${repo}.git`,
silent: !verbose,
dotfiles,
beforeAdd,
};

return new Promise((resolve, reject) => {
Expand Down
2 changes: 2 additions & 0 deletions lib/deployment/pages/pages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('Github pages', () => {
repo: 'a-repo',
dotfiles: true,
verbose: true,
beforeAdd: './beforeAdd.js',
};
expect(ghpages.publish).not.toBeCalled();
await deployDirectoryToGithubPages('a-directory', options);
Expand All @@ -25,6 +26,7 @@ describe('Github pages', () => {
repo: 'https://[email protected]/an-owner/a-repo.git',
silent: false,
dotfiles: true,
beforeAdd: './beforeAdd.js',
},
expect.any(Function),
);
Expand Down
1 change: 1 addition & 0 deletions lib/options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function extendWithDefaultOptions(options) {
defaultBranch: 'master',
dotfiles: false,
verbose: false,
beforeAdd: null,
...options,
};
}
Expand Down
5 changes: 5 additions & 0 deletions lib/options/options.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('Options', () => {
defaultBranch: 'master',
dotfiles: false,
verbose: false,
beforeAdd: null,
});
});

Expand All @@ -29,6 +30,7 @@ describe('Options', () => {
directory: 'a-directory',
dotfiles: true,
verbose: true,
beforeAdd: null,
};
expect(createOptions(options)).toEqual(options);
});
Expand All @@ -44,6 +46,7 @@ describe('Options', () => {
directory: 'a-directory',
dotfiles: true,
verbose: true,
beforeAdd: null,
};
expect(createOptions(options)).toEqual({ ...options, token: 'a-token' });
});
Expand All @@ -67,6 +70,7 @@ describe('Options', () => {
directory: 'a-directory',
dotfiles: false,
verbose: false,
beforeAdd: null,
});

delete process.env.CIRCLECI;
Expand Down Expand Up @@ -94,6 +98,7 @@ describe('Options', () => {
dotfiles: false,
verbose: false,
defaultBranch: 'master',
beforeAdd: null,
});

delete process.env.GITHUB_WORKFLOW;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deploy-to-github-pages",
"version": "1.0.1",
"version": "1.1.0",
"description": "A Node library that makes deploying a directory on a branch to GitHub pages easy and automatic.",
"bin": {
"deploy-to-github-pages": "bin/deploy-to-github-pages.js"
Expand Down