Skip to content
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
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const cli = meow(
Defaults to 3
e.g /blog/1, /blog/2, /blog/3
--reference-url Allows a reference URL to be used in testing
--strip-querystring Strips the query string from pages
--max-depth Maximum depth to crawl

Examples
$ backstop-crawl http://localhost
Expand All @@ -49,6 +51,15 @@ if (cli.flags.limitSimilar) {
}
}

if (cli.flags.maxDepth) {
if (!Number.isInteger(cli.flags.maxDepth)) {
console.error(
`> Error: "${cli.flags.maxDepth}" isn't a valid depth`
);
process.exit(1);
}
}

if (cli.flags.referenceUrl) {

if (!validurl(cli.flags.referenceUrl)) {
Expand Down
8 changes: 8 additions & 0 deletions lib/crawl.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ function crawl(url, flags) {
crawler.scanSubdomains = true;
}

if (flags.maxDepth) {
crawler.maxDepth = flags.maxDepth;
}

if (flags.stripQuerystring) {
crawler.stripQuerystring = true;
}

// Skip this small blacklist of extensions
crawler.addFetchCondition(
queueItem => !queueItem.path.match(EXT_BLACKLIST)
Expand Down