lib/cli/options

Main entry point for handling filesystem-based configuration,
whether that's mocha.opts or a config file or package.json or whatever.

Source:

(require("lib/cli/options"))()

Source:
Deprecated:
  • Deprecated in v6.0.0; This function is no longer used internally and will be removed in a future version.
See:

Prepends options from run-control file to the command line arguments.

Methods

(static) loadMochaOpts(argsopt) → {external:yargsParser.Arguments|void}

Source:

Given filepath in args.opts, attempt to load and parse a mocha.opts file.

Parameters:
Name Type Attributes Description
args Object <optional>

Arguments object

Properties
Name Type Attributes Description
opts string | boolean <optional>

Filepath to mocha.opts; defaults to whatever's in mocharc.opts, or false to skip

Returns:

If read, object containing parsed arguments

Type
external:yargsParser.Arguments | void

(static) loadOptions(argvopt) → {external:yargsParser.Arguments}

Parses options read from mocha.opts, .mocharc.* and package.json.

Source:

Priority list:

  1. Command-line args
  2. RC file (.mocharc.js, .mocharc.ya?ml, mocharc.json)
  3. mocha prop of package.json
  4. mocha.opts
  5. default configuration (lib/mocharc.json)

If a "one-and-done" option is present in the argv array, no external config files will be read.

Parameters:
Name Type Attributes Description
argv string | Array:.<string:> <optional>

Arguments to parse

Returns:

Parsed args from everything

Type
external:yargsParser.Arguments

(static) loadPkgRc(argsopt) → {external:yargsParser.Arguments|void}

Source:

Given path to package.json in args.package, attempt to load config from mocha prop.

Parameters:
Name Type Attributes Description
args Object <optional>

Arguments object

Properties
Name Type Attributes Description
config string | boolean <optional>

Path to package.json or false to skip

Returns:

Parsed config, or nothing if args.package is false

Type
external:yargsParser.Arguments | void

(static) loadRc(argsopt) → {external:yargsParser.Arguments|void}

Source:

Given path to config file in args.config, attempt to load & parse config file.

Parameters:
Name Type Attributes Description
args Object <optional>

Arguments object

Properties
Name Type Attributes Description
config string | boolean <optional>

Path to config file or false to skip

Returns:

Parsed config, or nothing if args.config is false

Type
external:yargsParser.Arguments | void