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

feat: Add CLI arg for projectBaseUrl #232

Merged
merged 3 commits into from
Mar 9, 2023
Merged
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions markdown-link-check
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function getInputs() {
.option('-v, --verbose', 'displays detailed error information')
.option('-a, --alive <code>', 'comma separated list of HTTP codes to be considered as alive', commaSeparatedCodesList)
.option('-r, --retry', 'retry after the duration indicated in \'retry-after\' header when HTTP code is 429')
.option('--projectBaseUrl <url>', 'the URL to use for {{BASEURL}} replacement')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this would be the only CLI arg without a shorthand option (-p was already taken for --progress).

.arguments('[filenamesOrUrls...]')
.action(function (filenamesOrUrls) {
let filenameForOutput;
Expand Down Expand Up @@ -102,8 +103,12 @@ function getInputs() {
input.opts.verbose = (program.verbose === true);
input.opts.retryOn429 = (program.retry === true);
input.opts.aliveStatusCodes = program.alive;
// set the projectBaseUrl to the current working directory, so that `{{BASEURL}}` can be resolved to the project root.
input.opts.projectBaseUrl = `file://${process.cwd()}`;
if (program.projectBaseUrl) {
input.opts.projectBaseUrl = `file://${program.projectBaseUrl}`;
} else {
// set the default projectBaseUrl to the current working directory, so that `{{BASEURL}}` can be resolved to the project root.
input.opts.projectBaseUrl = `file://${process.cwd()}`;
}
}

return inputs;
Expand Down