Home Manual Reference Source Test
public class | source

BrokenLinkChecker

The Command Line Interface.

Test:

Constructor Summary

Public Constructor
public

Creates a new BrokenLinkChecker with the specified options.

Member Summary

Public Members
public

The instance of express.Application used.

public get

The base url to use when serving files.

public

true if serving a directory is needed to run the check.

public

The parsed command line options used.

public

The path to check.

public

The server used.

public

The URL to check.

Private Members
private

The arguments to handle.

Method Summary

Public Methods
public

exit(code: number, err: Error): number

Exits BrokenLinkChecker with the specified exit code and (optionally) an error that occurred.

public

Sets either BrokenLinkChecker#path or BrokenLinkChecker#path from the first non-option argument provided.

public

launch(): *

Launches the CLI.

public

Runs blc on the given port or BrokenLinkChecker#url.

public

Starts a server serving BrokenLinkChecker#path on the speficied port.

public

Validates options.

Public Constructors

public constructor(argv: Array<string>) source

Creates a new BrokenLinkChecker with the specified options.

Params:

NameTypeAttributeDescription
argv Array<string>

The arguments to handle.

Public Members

public app: express.Application source

The instance of express.Application used.

public get baseUrl: string source

The base url to use when serving files.

public needServer: Boolean source

true if serving a directory is needed to run the check.

public options: Object source

The parsed command line options used.

public path: String source

The path to check. Only set if a path is given as input.

public server: http.Server source

The server used.

public url: String source

The URL to check. Only set if a URL is given as input.

Private Members

private _argv: String[] source

The arguments to handle.

Public Methods

public exit(code: number, err: Error): number source

Exits BrokenLinkChecker with the specified exit code and (optionally) an error that occurred.

Params:

NameTypeAttributeDescription
code number

The code to exit with.

err Error

The error to report.

Return:

number

Code The code to exit with.

Test:

public getPathOrUrl() source

Sets either BrokenLinkChecker#path or BrokenLinkChecker#path from the first non-option argument provided.

Test:

public launch(): * source

Launches the CLI.

Return:

*

Test:

public runChecker(port: number): Promise<number> source

Runs blc on the given port or BrokenLinkChecker#url.

Params:

NameTypeAttributeDescription
port number
  • optional

The port to check.

Return:

Promise<number>

Resolved with blc's exit code.

Test:

public startServer(port: number): Promise<number, Error> source

Starts a server serving BrokenLinkChecker#path on the speficied port.

Params:

NameTypeAttributeDescription
port number

The port to server on.

Return:

Promise<number, Error>

Resolved with the port used, rejected with an error if listening on the port failed.

Test:

public validateOptions(): Promise<Object, Error> source

Validates options.

Return:

Promise<Object, Error>

Fulfilled with the parsed options, rejected if validation failed.

Test: