Skip to content

Commit 4bf03da

Browse files
committed
feat: add basic ignore subpaths argument
Add a basic ignore subpaths argument. just checks if paths include it, no regex/glob/etc yet. Closes #102.
1 parent 1a5a675 commit 4bf03da

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

markdown-link-check

+16-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class Input {
1919
}
2020
}
2121

22+
function commaSeparatedPathsList(value) {
23+
return value.split(',');
24+
}
25+
2226
function commaSeparatedCodesList(value, dummyPrevious) {
2327
return value.split(',').map(function(item) {
2428
return parseInt(item, 10);
@@ -34,6 +38,7 @@ function getInputs() {
3438
.option('-c, --config [config]', 'apply a config file (JSON), holding e.g. url specific header configuration')
3539
.option('-q, --quiet', 'displays errors only')
3640
.option('-v, --verbose', 'displays detailed error information')
41+
.option('-i --ignore <paths>', 'ignore input paths including an ignore path', commaSeparatedPathsList)
3742
.option('-a, --alive <code>', 'comma separated list of HTTP codes to be considered as alive', commaSeparatedCodesList)
3843
.option('-r, --retry', 'retry after the duration indicated in \'retry-after\' header when HTTP code is 429')
3944
.option('--projectBaseUrl <url>', 'the URL to use for {{BASEURL}} replacement')
@@ -81,7 +86,16 @@ function getInputs() {
8186
console.error(chalk.red('\nERROR: ' + filenameOrUrl + ' is a directory! Please provide a valid filename as an argument.'));
8287
process.exit(1);
8388
}
84-
baseUrl = 'file://' + path.dirname(path.resolve(filenameOrUrl));
89+
90+
const resolved = path.resolve(filenameOrUrl);
91+
92+
// skip paths given if it includes a path to ignore.
93+
// todo: allow ignore paths to be glob or regex instead of just includes?
94+
if (program.opts().ignore.some((ignorePath) => resolved.includes(ignorePath))) {
95+
continue;
96+
}
97+
98+
baseUrl = 'file://' + path.dirname(resolved);
8599
stream = fs.createReadStream(filenameOrUrl);
86100
}
87101

@@ -100,7 +114,7 @@ function getInputs() {
100114
if (config) {
101115
input.opts.config = config.trim();
102116
}
103-
117+
104118
if (program.projectBaseUrl) {
105119
input.opts.projectBaseUrl = `file://${program.projectBaseUrl}`;
106120
} else {

0 commit comments

Comments
 (0)