Skip to content

Commit

Permalink
fix(protractor): extend config with argv
Browse files Browse the repository at this point in the history
This ensures extending the config with passed argv object
  • Loading branch information
Christoffer Åström committed Jan 10, 2018
1 parent 225613c commit 6b7e7eb
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/protractor/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint global-require: 0, no-console: 0, import/no-unresolved: 0, import/no-extraneous-dependencies: 0, import/no-dynamic-require: 0, max-len: 0 */
const path = require('path');
const globby = require('globby');
const initConfig = require('./config');
const extend = require('extend');
const fs = require('fs');
Expand All @@ -9,13 +8,13 @@ const options = require('./options');
const protractor = {
command: ['protractor', 'ptor'],
desc: 'Run protractor',
getConfig(configPath) {
getConfig(argv) {
const baseConfig = initConfig();
if (!fs.existsSync(configPath)) {
throw new Error(`Config ${configPath} not found`);
if (!fs.existsSync(argv.config)) {
throw new Error(`Config ${argv.config} not found`);
}
let config = {};
const p = path.resolve(process.cwd(), configPath);
const p = path.resolve(process.cwd(), argv.config);
const foundConfig = require(p);
if (typeof foundConfig === 'function') {
config = extend(true, baseConfig, foundConfig(baseConfig));
Expand Down Expand Up @@ -43,16 +42,11 @@ const protractor = {
process.exit(1);
}
}
const config = protractor.getConfig(argv.config);
const config = protractor.getConfig(argv);
argv.require.map(require);
if (argv.glob.length) {
config.specs = argv.glob;
}
const files = globby.sync(config.specs);
if (!files.length) {
console.log('No files found for:', config.specs);
process.exit(1);
}

launcher.init('', config);
},
Expand Down

0 comments on commit 6b7e7eb

Please sign in to comment.