1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const url = require("url");
|
4 | const config_1 = require("../models/config");
|
5 | const require_project_module_1 = require("../utilities/require-project-module");
|
6 | const Task = require('../ember-cli/lib/models/task');
|
7 | const SilentError = require('silent-error');
|
8 | exports.E2eTask = Task.extend({
|
9 | run: function (e2eTaskOptions) {
|
10 | const projectConfig = config_1.CliConfig.fromProject().config;
|
11 | const projectRoot = this.project.root;
|
12 | const protractorLauncher = require_project_module_1.requireProjectModule(projectRoot, 'protractor/built/launcher');
|
13 | if (projectConfig.project && projectConfig.project.ejected) {
|
14 | throw new SilentError('An ejected project cannot use the build command anymore.');
|
15 | }
|
16 | return new Promise(function () {
|
17 | let promise = Promise.resolve();
|
18 | let additionalProtractorConfig = {
|
19 | elementExplorer: e2eTaskOptions.elementExplorer
|
20 | };
|
21 |
|
22 | if (e2eTaskOptions.serve) {
|
23 | additionalProtractorConfig.baseUrl = url.format({
|
24 | protocol: e2eTaskOptions.ssl ? 'https' : 'http',
|
25 | hostname: e2eTaskOptions.host,
|
26 | port: e2eTaskOptions.port.toString()
|
27 | });
|
28 | }
|
29 | if (e2eTaskOptions.specs.length !== 0) {
|
30 | additionalProtractorConfig['specs'] = e2eTaskOptions.specs;
|
31 | }
|
32 | if (e2eTaskOptions.webdriverUpdate) {
|
33 |
|
34 |
|
35 | const webdriverUpdate = require_project_module_1.requireProjectModule(projectRoot, 'protractor/node_modules/webdriver-manager/built/lib/cmds/update');
|
36 |
|
37 |
|
38 | promise = promise.then(() => webdriverUpdate.program.run({
|
39 | standalone: false,
|
40 | gecko: false,
|
41 | quiet: true
|
42 | }));
|
43 | }
|
44 |
|
45 | return promise.then(() => protractorLauncher.init(e2eTaskOptions.config, additionalProtractorConfig));
|
46 | });
|
47 | }
|
48 | });
|
49 |
|
\ | No newline at end of file |