Skip to content

Commit cedaaeb

Browse files
authored
Merge pull request #278 from CanadaHonk/ignore-option
feat: add basic ignore subpaths argument
2 parents ee023b8 + 4bf03da commit cedaaeb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

markdown-link-check

+15-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class Input {
2020
}
2121
}
2222

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

0 commit comments

Comments
 (0)