linkinator
Advanced tools
Comparing version 2.11.2 to 2.12.0
@@ -34,2 +34,6 @@ #!/usr/bin/env node | ||
--directory-listing | ||
Include an automatic directory index file when linking to a directory. | ||
Defaults to 'false'. | ||
--format, -f | ||
@@ -79,2 +83,3 @@ Return the data in CSV or JSON format. | ||
verbosity: { type: 'string' }, | ||
directoryListing: { type: 'boolean' }, | ||
}, | ||
@@ -120,2 +125,3 @@ booleanDefault: undefined, | ||
serverRoot: flags.serverRoot, | ||
directoryListing: flags.directoryListing, | ||
}; | ||
@@ -122,0 +128,0 @@ if (flags.skip) { |
@@ -11,3 +11,4 @@ export interface Flags { | ||
serverRoot?: string; | ||
directoryListing?: boolean; | ||
} | ||
export declare function getConfig(flags: Flags): Promise<Flags>; |
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import { URL } from 'url'; | ||
import PQueue, { DefaultAddOptions } from 'p-queue'; | ||
import { URL } from 'url'; | ||
import PriorityQueue from 'p-queue/dist/priority-queue'; | ||
@@ -15,2 +15,3 @@ export interface CheckOptions { | ||
serverRoot?: string; | ||
directoryListing?: boolean; | ||
} | ||
@@ -65,11 +66,2 @@ export declare enum LinkState { | ||
/** | ||
* Spin up a local HTTP server to serve static requests from disk | ||
* @param root The local path that should be mounted as a static web server | ||
* @param port The port on which to start the local web server | ||
* @param markdown If markdown should be automatically compiled and served | ||
* @private | ||
* @returns Promise that resolves with the instance of the HTTP server | ||
*/ | ||
private startWebServer; | ||
/** | ||
* Crawl a given url with the provided options. | ||
@@ -76,0 +68,0 @@ * @pram opts List of options used to do the crawl |
@@ -5,17 +5,12 @@ "use strict"; | ||
const events_1 = require("events"); | ||
const gaxios_1 = require("gaxios"); | ||
const http = require("http"); | ||
const enableDestroy = require("server-destroy"); | ||
const finalhandler = require("finalhandler"); | ||
const serveStatic = require("serve-static"); | ||
const url_1 = require("url"); | ||
const fs = require("fs"); | ||
const util = require("util"); | ||
const path = require("path"); | ||
const marked = require("marked"); | ||
const gaxios_1 = require("gaxios"); | ||
const p_queue_1 = require("p-queue"); | ||
const globby = require("glob"); | ||
const links_1 = require("./links"); | ||
const url_1 = require("url"); | ||
const server_1 = require("./server"); | ||
const stat = util.promisify(fs.stat); | ||
const readFile = util.promisify(fs.readFile); | ||
const glob = util.promisify(globby); | ||
@@ -51,4 +46,8 @@ var LinkState; | ||
const port = options.port || 5000 + Math.round(Math.random() * 1000); | ||
server = await this.startWebServer(options.serverRoot, port, options.markdown); | ||
enableDestroy(server); | ||
server = await server_1.startWebServer({ | ||
root: options.serverRoot, | ||
port, | ||
markdown: options.markdown, | ||
directoryListing: options.directoryListing, | ||
}); | ||
for (let i = 0; i < options.path.length; i++) { | ||
@@ -108,2 +107,6 @@ if (options.path[i].startsWith('/')) { | ||
} | ||
// disable directory listings by default | ||
if (options.directoryListing === undefined) { | ||
options.directoryListing = false; | ||
} | ||
// Ensure we do not mix http:// and file system paths. The paths passed in | ||
@@ -195,35 +198,2 @@ // must all be filesystem paths, or HTTP paths. | ||
/** | ||
* Spin up a local HTTP server to serve static requests from disk | ||
* @param root The local path that should be mounted as a static web server | ||
* @param port The port on which to start the local web server | ||
* @param markdown If markdown should be automatically compiled and served | ||
* @private | ||
* @returns Promise that resolves with the instance of the HTTP server | ||
*/ | ||
async startWebServer(root, port, markdown) { | ||
return new Promise((resolve, reject) => { | ||
const serve = serveStatic(root); | ||
const server = http | ||
.createServer(async (req, res) => { | ||
const pathParts = req.url.split('/').filter(x => !!x); | ||
if (pathParts.length > 0) { | ||
const ext = path.extname(pathParts[pathParts.length - 1]); | ||
if (markdown && ext.toLowerCase() === '.md') { | ||
const filePath = path.join(path.resolve(root), req.url); | ||
const data = await readFile(filePath, { encoding: 'utf-8' }); | ||
const result = marked(data, { gfm: true }); | ||
res.writeHead(200, { | ||
'content-type': 'text/html', | ||
}); | ||
res.end(result); | ||
return; | ||
} | ||
} | ||
return serve(req, res, finalhandler(req, res)); | ||
}) | ||
.listen(port, () => resolve(server)) | ||
.on('error', reject); | ||
}); | ||
} | ||
/** | ||
* Crawl a given url with the provided options. | ||
@@ -230,0 +200,0 @@ * @pram opts List of options used to do the crawl |
{ | ||
"name": "linkinator", | ||
"description": "Find broken links, missing images, etc in your HTML. Scurry around your site and find all those broken links.", | ||
"version": "2.11.2", | ||
"version": "2.12.0", | ||
"license": "MIT", | ||
@@ -26,3 +26,2 @@ "repository": "JustinBeckwith/linkinator", | ||
"cheerio": "^1.0.0-rc.2", | ||
"finalhandler": "^1.1.2", | ||
"gaxios": "^4.0.0", | ||
@@ -34,3 +33,3 @@ "glob": "^7.1.6", | ||
"p-queue": "^6.2.1", | ||
"serve-static": "^1.14.1", | ||
"serve-handler": "^6.1.3", | ||
"server-destroy": "^1.0.1", | ||
@@ -42,3 +41,2 @@ "update-notifier": "^5.0.0" | ||
"@types/cheerio": "0.22.22", | ||
"@types/finalhandler": "^1.1.0", | ||
"@types/glob": "^7.1.3", | ||
@@ -49,3 +47,3 @@ "@types/marked": "^1.2.0", | ||
"@types/node": "^12.7.12", | ||
"@types/serve-static": "^1.13.8", | ||
"@types/serve-handler": "^6.1.0", | ||
"@types/server-destroy": "^1.0.0", | ||
@@ -52,0 +50,0 @@ "@types/sinon": "^9.0.0", |
@@ -48,2 +48,6 @@ # 🐿 linkinator | ||
--directory-listing | ||
Include an automatic directory index file when linking to a directory. | ||
Defaults to 'false'. | ||
--format, -f | ||
@@ -142,2 +146,3 @@ Return the data in CSV or JSON format. | ||
"markdown": true, | ||
"directoryListing": true, | ||
"skip": "www.googleapis.com" | ||
@@ -166,2 +171,3 @@ } | ||
- `linksToSkip` (array | function) - An array of regular expression strings that should be skipped, OR an async function that's called for each link with the link URL as its only argument. Return a Promise that resolves to `true` to skip the link or `false` to check it. | ||
- `directoryListing` (boolean) - Automatically serve a static file listing page when serving a directory. Defaults to `false`. | ||
@@ -168,0 +174,0 @@ #### linkinator.LinkChecker() |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76205
11
22
21
1009
300
5
+ Addedserve-handler@^6.1.3
+ Addedbytes@3.0.0(transitive)
+ Addedcontent-disposition@0.5.2(transitive)
+ Addedmime-db@1.33.0(transitive)
+ Addedmime-types@2.1.18(transitive)
+ Addedpath-is-inside@1.0.2(transitive)
+ Addedpath-to-regexp@3.3.0(transitive)
+ Addedrange-parser@1.2.0(transitive)
+ Addedserve-handler@6.1.6(transitive)
- Removedfinalhandler@^1.1.2
- Removedserve-static@^1.14.1
- Removeddebug@2.6.9(transitive)
- Removeddepd@2.0.0(transitive)
- Removeddestroy@1.2.0(transitive)
- Removedee-first@1.1.1(transitive)
- Removedencodeurl@1.0.22.0.0(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedetag@1.8.1(transitive)
- Removedfinalhandler@1.3.1(transitive)
- Removedfresh@0.5.2(transitive)
- Removedhttp-errors@2.0.0(transitive)
- Removedmime@1.6.0(transitive)
- Removedms@2.0.0(transitive)
- Removedon-finished@2.4.1(transitive)
- Removedparseurl@1.3.3(transitive)
- Removedrange-parser@1.2.1(transitive)
- Removedsend@0.19.0(transitive)
- Removedserve-static@1.16.2(transitive)
- Removedsetprototypeof@1.2.0(transitive)
- Removedstatuses@2.0.1(transitive)
- Removedtoidentifier@1.0.1(transitive)
- Removedunpipe@1.0.0(transitive)