Skip to content

Commit fd18f41

Browse files
author
trik
committed
build: prevent binding BrowserSync UI server during test execution
1 parent 69029b4 commit fd18f41

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

tools/dev-server/dev-server.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ export class DevServer {
3838
};
3939

4040
constructor(
41-
readonly port: number, private _rootPaths: string[],
42-
private _historyApiFallback: boolean = false) {}
41+
readonly port: number, private _rootPaths: string[], bindUi: boolean,
42+
private _historyApiFallback: boolean = false) {
43+
if (bindUi === false) {
44+
this.options.ui = false;
45+
}
46+
}
4347

4448
/** Starts the server on the given port. */
4549
start() {

tools/dev-server/ibazel.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ import {DevServer} from './dev-server';
1212
// ibazel will write this string after a successful build.
1313
const ibazelNotifySuccessMessage = 'IBAZEL_BUILD_COMPLETED SUCCESS';
1414

15+
export function isIBazelProcess() {
16+
return process.env['IBAZEL_NOTIFY_CHANGES'] === 'y';
17+
}
18+
1519
/**
1620
* Sets up ibazel support for the specified devserver. ibazel communicates with
1721
* an executable over the "stdin" interface. Whenever a specific message is sent
1822
* over "stdin", the devserver can be reloaded.
1923
*/
2024
export function setupBazelWatcherSupport(server: DevServer) {
2125
// If iBazel is not configured for this process, we do not setup the watcher.
22-
if (process.env['IBAZEL_NOTIFY_CHANGES'] !== 'y') {
26+
if (!isIBazelProcess()) {
2327
return;
2428
}
2529

tools/dev-server/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
import minimist from 'minimist';
1010

1111
import {DevServer} from './dev-server';
12-
import {setupBazelWatcherSupport} from './ibazel';
12+
import {isIBazelProcess, setupBazelWatcherSupport} from './ibazel';
1313

1414
const args = process.argv.slice(2);
1515
const {root_paths: _rootPathsRaw, port, historyApiFallback} =
1616
minimist(args, {boolean: 'historyApiFallback'});
1717
const rootPaths = _rootPathsRaw ? _rootPathsRaw.split(',') : ['/'];
1818

19-
const server = new DevServer(port, rootPaths, historyApiFallback);
19+
const bindUi = isIBazelProcess();
20+
const server = new DevServer(port, rootPaths, bindUi, historyApiFallback);
2021

2122
// Setup ibazel support.
2223
setupBazelWatcherSupport(server);

0 commit comments

Comments
 (0)