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

Dependency updates and drop Node 14 #507

Merged
merged 2 commits into from
Aug 11, 2023
Merged
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: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
os:
- ubuntu-latest
node:
- 14
- 16
- 18
- 20

steps:
- name: Clone repository
Expand Down
64 changes: 31 additions & 33 deletions bin/gh-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@ const path = require('path');
const pkg = require('../package.json');
const addr = require('email-addresses');

function publish(program, config) {
function publish(dist, config) {
return new Promise((resolve, reject) => {
if (program.dist === undefined) {
return reject(
new Error(
'No base directory specified. The `--dist` option must be specified.'
)
);
}
const basePath = path.resolve(process.cwd(), program.dist);
const basePath = path.resolve(process.cwd(), dist);
ghpages.publish(basePath, config, (err) => {
if (err) {
return reject(err);
Expand All @@ -29,7 +22,10 @@ function main(args) {
return Promise.resolve().then(() => {
const program = new Command()
.version(pkg.version)
.option('-d, --dist <dist>', 'Base directory for all source files')
.requiredOption(
'-d, --dist <dist>',
'Base directory for all source files'
)
.option(
'-s, --src <src>',
'Pattern used to select which files to publish',
Expand Down Expand Up @@ -83,20 +79,22 @@ function main(args) {
)
.parse(args);

const options = program.opts();

let user;
if (program.user) {
const parts = addr.parseOneAddress(program.user);
if (options.user) {
const parts = addr.parseOneAddress(options.user);
if (!parts) {
throw new Error(
`Could not parse name and email from user option "${program.user}" ` +
`Could not parse name and email from user option "${options.user}" ` +
'(format should be "Your Name <[email protected]>")'
);
}
user = {name: parts.name, email: parts.address};
}
let beforeAdd;
if (program.beforeAdd) {
const m = require(require.resolve(program.beforeAdd, {
if (options.beforeAdd) {
const m = require(require.resolve(options.beforeAdd, {
paths: [process.cwd()],
}));

Expand All @@ -107,32 +105,32 @@ function main(args) {
} else {
throw new Error(
`Could not find function to execute before adding files in ` +
`"${program.beforeAdd}".\n `
`"${options.beforeAdd}".\n `
);
}
}

const config = {
repo: program.repo,
silent: !!program.silent,
branch: program.branch,
src: program.src,
dest: program.dest,
message: program.message,
tag: program.tag,
git: program.git,
depth: program.depth,
dotfiles: !!program.dotfiles,
add: !!program.add,
remove: program.remove,
remote: program.remote,
push: !!program.push,
history: !!program.history,
repo: options.repo,
silent: !!options.silent,
branch: options.branch,
src: options.src,
dest: options.dest,
message: options.message,
tag: options.tag,
git: options.git,
depth: options.depth,
dotfiles: !!options.dotfiles,
add: !!options.add,
remove: options.remove,
remote: options.remote,
push: !!options.push,
history: !!options.history,
user: user,
beforeAdd: beforeAdd,
};

return publish(program, config);
return publish(options.dist, config);
});
}

Expand All @@ -142,7 +140,7 @@ if (require.main === module) {
process.stdout.write('Published\n');
})
.catch((err) => {
process.stderr.write(`${err.message}\n`, () => process.exit(1));
process.stderr.write(`${err.stack}\n`, () => process.exit(1));
});
}

Expand Down
Loading