From 5a67b6bc05e7ad76d2247e6a27401f0f454aa76b Mon Sep 17 00:00:00 2001 From: Abhijeeth Padarthi Date: Sun, 24 Mar 2019 22:16:51 +0530 Subject: [PATCH 1/3] refactor to fix lints. --- lib/launcher.ts | 3 +- lib/runnerCli.ts | 92 +++++++++++++++++++++++------------------------- 2 files changed, 46 insertions(+), 49 deletions(-) diff --git a/lib/launcher.ts b/lib/launcher.ts index 2ce5d6ed3..3475a8433 100644 --- a/lib/launcher.ts +++ b/lib/launcher.ts @@ -55,8 +55,7 @@ class TaskResults { let processFailures = this.totalProcessFailures(); this.results_.forEach((result: any) => { let capabilities = result.capabilities; - let shortName = (capabilities.browserName) ? capabilities.browserName : ''; - shortName = (capabilities.logName) ? + let shortName = (capabilities.logName) ? capabilities.logName : (capabilities.browserName) ? capabilities.browserName : ''; shortName += (capabilities.version) ? capabilities.version : ''; diff --git a/lib/runnerCli.ts b/lib/runnerCli.ts index 2f13116c4..9fb86a025 100644 --- a/lib/runnerCli.ts +++ b/lib/runnerCli.ts @@ -10,52 +10,50 @@ import {Runner} from './runner'; let logger = new Logger('runnerCli'); process.on('message', (m: any) => { - switch (m.command) { - case 'run': - if (!m.capabilities) { - throw new Error('Run message missing capabilities'); - } - // Merge in config file options. - let configParser = new ConfigParser(); - if (m.configFile) { - configParser.addFileConfig(m.configFile); - } - if (m.additionalConfig) { - configParser.addConfig(m.additionalConfig); - } - let config = configParser.getConfig(); - Logger.set(config); - - // Grab capabilities to run from launcher. - config.capabilities = m.capabilities; - - // Get specs to be executed by this runner - config.specs = m.specs; - - // Launch test run. - let runner = new Runner(config); - - // Pipe events back to the launcher. - runner.on('testPass', () => { - process.send({event: 'testPass'}); - }); - runner.on('testFail', () => { - process.send({event: 'testFail'}); - }); - runner.on('testsDone', (results: any) => { - process.send({event: 'testsDone', results: results}); - }); - - runner.run() - .then((exitCode: number) => { - process.exit(exitCode); - }) - .catch((err: Error) => { - logger.info(err.message); - process.exit(1); - }); - break; - default: - throw new Error('command ' + m.command + ' is invalid'); + if(m.command == 'run') { + if (!m.capabilities) { + throw new Error('Run message missing capabilities'); + } + // Merge in config file options. + let configParser = new ConfigParser(); + if (m.configFile) { + configParser.addFileConfig(m.configFile); + } + if (m.additionalConfig) { + configParser.addConfig(m.additionalConfig); + } + let config = configParser.getConfig(); + Logger.set(config); + + // Grab capabilities to run from launcher. + config.capabilities = m.capabilities; + + // Get specs to be executed by this runner + config.specs = m.specs; + + // Launch test run. + let runner = new Runner(config); + + // Pipe events back to the launcher. + runner.on('testPass', () => { + process.send({event: 'testPass'}); + }); + runner.on('testFail', () => { + process.send({event: 'testFail'}); + }); + runner.on('testsDone', (results: any) => { + process.send({event: 'testsDone', results: results}); + }); + + runner.run() + .then((exitCode: number) => { + process.exit(exitCode); + }) + .catch((err: Error) => { + logger.info(err.message); + process.exit(1); + }); + } else { + throw new Error('command ' + m.command + ' is invalid'); } }); From 54601f92caf40ffb7543700ccc3f1897b438f515 Mon Sep 17 00:00:00 2001 From: Abhijeeth Padarthi Date: Sun, 24 Mar 2019 22:40:09 +0530 Subject: [PATCH 2/3] fixed lint error @ runnerCli.ts --- lib/runnerCli.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/runnerCli.ts b/lib/runnerCli.ts index 9fb86a025..01d0b98fd 100644 --- a/lib/runnerCli.ts +++ b/lib/runnerCli.ts @@ -10,7 +10,7 @@ import {Runner} from './runner'; let logger = new Logger('runnerCli'); process.on('message', (m: any) => { - if(m.command == 'run') { + if (m.command == 'run') { if (!m.capabilities) { throw new Error('Run message missing capabilities'); } From a95038a144869afdfb48ed2132f31fd2a01dbc28 Mon Sep 17 00:00:00 2001 From: Abhijeeth Padarthi Date: Mon, 25 Mar 2019 07:25:56 +0530 Subject: [PATCH 3/3] Replace == with === --- lib/runnerCli.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/runnerCli.ts b/lib/runnerCli.ts index 01d0b98fd..9cd8a1312 100644 --- a/lib/runnerCli.ts +++ b/lib/runnerCli.ts @@ -10,7 +10,7 @@ import {Runner} from './runner'; let logger = new Logger('runnerCli'); process.on('message', (m: any) => { - if (m.command == 'run') { + if (m.command === 'run') { if (!m.capabilities) { throw new Error('Run message missing capabilities'); }