/
cli.js
73 lines (63 loc) · 2.36 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* The command line interface for interacting with the Protractor runner.
* It takes care of parsing the config file and command line options.
*/
var util = require('util');
var path = require('path')
var fs = require('fs');
var runner = require('./runner.js');
var argv = require('optimist').
usage('Usage: protractor [options] [config]').
describe('version', 'Print Protractor version').
describe('browser', 'Browsername, e.g. chrome or firefox').
describe('seleniumAddress', 'A running seleium address to use').
describe('seleniumServerJar', 'Location of the standalone selenium jar file').
describe('seleniumPort', 'Optional port for the selenium standalone server').
describe('baseUrl', 'URL to prepend to all relative paths').
describe('rootElement', 'Element housing ng-app, if not html or body').
describe('specs', 'Comma-separated list of files to test').
describe('verbose', 'Print full spec names').
describe('includeStackTrace', 'Print stack trace on error').
describe('params', 'Param object to be passed to the tests').
alias('browser', 'capabilities.browserName').
alias('name', 'capabilities.name').
alias('platform', 'capabilities.platform').
alias('platform-version', 'capabilities.version').
alias('tags', 'capabilities.tags').
alias('build', 'capabilities.build').
boolean('verbose').
boolean('includeStackTrace').
alias('verbose', 'jasmineNodeOpts.isVerbose').
alias('includeStackTrace', 'jasmineNodeOpts.includeStackTrace').
check(function(arg) {
if (arg._.length > 1) {
throw 'Error: more than one config file specified'
}
if (!(process.argv.length > 2)) {
throw '';
}
}).
argv;
var configPath;
var printVersion = function () {
util.puts('Version ' + JSON.parse(
fs.readFileSync(__dirname + '/../package.json', 'utf8')).version);
process.exit(0);
};
if (argv.version) {
printVersion();
}
if (argv.specs) {
argv.specs = argv.specs.split(',');
argv.specs.forEach(function(spec, index, arr) {
arr[index] = path.resolve(process.cwd(), spec);
});
}
var configFilename = argv._[0];
if (configFilename) {
configPath = path.resolve(process.cwd(), configFilename);
runner.addConfig(require(configPath).config);
runner.addConfig({specFileBase: path.dirname(configPath)})
}
runner.addConfig(argv);
runner.runOnce();