Skip to content

Commit

Permalink
fix: add warning for deprecated use of CLI options
Browse files Browse the repository at this point in the history
  • Loading branch information
npetruzzelli committed Mar 5, 2021
1 parent 088aa79 commit 5d92865
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ function parseExitCode (buffer, defaultExitCode, failOnEmptyTestSuite) {
function run (cliOptionsOrConfig, done) {
cliOptionsOrConfig = cliOptionsOrConfig || {}

// TODO: Should `const log = logger.create('runner')` be moved into the
// : function for consistency with server.js and stopper.js? or the
// : reverse (make server and stopper consistent with runner?)
logger.setupFromConfig({
colors: cliOptionsOrConfig.colors,
logLevel: cliOptionsOrConfig.logLevel
Expand All @@ -46,6 +49,12 @@ function run (cliOptionsOrConfig, done) {
if (cliOptionsOrConfig instanceof cfg.Config) {
config = cliOptionsOrConfig
} else {
const deprecatedCliOptionsMessage =
'Passing raw CLI options to `runner(config, done)` is deprecated. Use ' +
'`parseConfig(configFilePath, cliOptions, {promiseConfig: true, throwErrors: true})` ' +
'to prepare a processed `Config` instance and pass that as the ' +
'`config` argument instead.'
log.warn(deprecatedCliOptionsMessage)
try {
config = cfg.parseConfig(
cliOptionsOrConfig.configFile,
Expand Down
7 changes: 7 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ class Server extends KarmaEventEmitter {
if (cliOptionsOrConfig instanceof cfg.Config) {
config = cliOptionsOrConfig
} else {
const deprecatedCliOptionsMessage =
'Passing raw CLI options to `new Server(config, done)` is ' +
'deprecated. Use ' +
'`parseConfig(configFilePath, cliOptions, {promiseConfig: true, throwErrors: true})` ' +
'to prepare a processed `Config` instance and pass that as the ' +
'`config` argument instead.'
this.log.warn(deprecatedCliOptionsMessage)
try {
config = cfg.parseConfig(
cliOptionsOrConfig.configFile,
Expand Down
6 changes: 6 additions & 0 deletions lib/stopper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ exports.stop = function (cliOptionsOrConfig, done) {
if (cliOptionsOrConfig instanceof cfg.Config) {
config = cliOptionsOrConfig
} else {
const deprecatedCliOptionsMessage =
'Passing raw CLI options to `stopper(config, done)` is deprecated. Use ' +
'`parseConfig(configFilePath, cliOptions, {promiseConfig: true, throwErrors: true})` ' +
'to prepare a processed `Config` instance and pass that as the ' +
'`config` argument instead.'
log.warn(deprecatedCliOptionsMessage)
try {
config = cfg.parseConfig(
cliOptionsOrConfig.configFile,
Expand Down

0 comments on commit 5d92865

Please sign in to comment.