Skip to content

Commit

Permalink
chore: fix protractor
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eagle committed Dec 2, 2020
1 parent 490f886 commit c2686c1
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/protractor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ nodejs_test(
ts_library(
name = "protractor",
srcs = ["protractor-utils.ts"],
module_name = "@bazel/protractor/protractor-utils",
data = ["package.json"],
module_name = "@bazel/protractor",
module_root = "protractor-utils",
deps = ["@npm//@types/node"],
)
Expand Down
3 changes: 2 additions & 1 deletion packages/protractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
"protractor",
"bazel"
],
"main": "protractor-utils.js",
"peerDependencies": {
"protractor": ">=5.0.0"
},
"scripts": {
"postinstall": "node npm_version_check.js"
}
}
}
3 changes: 2 additions & 1 deletion packages/protractor/protractor-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/

const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']!);
import * as child_process from 'child_process';
import * as net from 'net';

Expand Down Expand Up @@ -98,7 +99,7 @@ export interface ServerSpec {
export async function runServer(
workspace: string, serverTarget: string, portFlag: string, serverArgs: string[],
timeout = 5000): Promise<ServerSpec> {
const serverPath = require.resolve(`${workspace}/${serverTarget}`);
const serverPath = runfiles.resolve(`${workspace}/${serverTarget}`);
const port = await findFreeTcpPort();

// Start the Bazel server binary with a random free TCP port.
Expand Down
5 changes: 3 additions & 2 deletions packages/protractor/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']);
const path = require('path');

function log_verbose(...m) {
Expand Down Expand Up @@ -76,7 +77,7 @@ let conf = {};

// Import the user's base protractor configuration if specified
if (configPath) {
const baseConf = require(configPath);
const baseConf = require(runfiles.resolve(configPath));
if (!baseConf.config) {
throw new Error('Invalid base protractor configuration. Expected config to be exported.');
}
Expand All @@ -86,7 +87,7 @@ if (configPath) {

// Import the user's on prepare function if specified
if (onPreparePath) {
const onPrepare = require(onPreparePath);
const onPrepare = require(runfiles.resolve(onPreparePath));
if (typeof onPrepare === 'function') {
const original = conf.onPrepare;
conf.onPrepare = function() {
Expand Down
1 change: 1 addition & 0 deletions packages/protractor/test/protractor-utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ jasmine_node_test(
srcs = [":protractor_utils_tests_lib"],
data = [
":fake-devserver",
"//packages/protractor",
],
)
2 changes: 1 addition & 1 deletion packages/protractor/test/protractor-utils/index_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import {runServer} from '@bazel/protractor/protractor-utils';
import {runServer} from '@bazel/protractor';

describe('Bazel protractor utils', () => {
it('should be able to start devserver', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/protractor/test/protractor/conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import * as protractorUtils from '@bazel/protractor/protractor-utils';
import * as protractorUtils from '@bazel/protractor';
import {browser} from 'protractor';

const http = require('http');
Expand Down

0 comments on commit c2686c1

Please sign in to comment.