Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit e2f73c7

Browse files
authored
fix(bonjour): updates dependency + better error handling (#1040)
1 parent f3f9dd2 commit e2f73c7

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"dependencies": {
3434
"autoprefixer": "6.7.2",
3535
"babili": "0.0.10",
36-
"bonjour": "^3.5.0",
36+
"bonjour": "github:resin-io/bonjour",
3737
"chalk": "1.1.3",
3838
"chokidar": "1.7.0",
3939
"clean-css": "3.4.24",

src/dev-server/bonjour.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,26 @@ import { getProjectJson } from '../util/ionic-project';
33
import { ServeConfig } from './serve-config';
44

55
export function createBonjourService(config: ServeConfig) {
6-
if (!config.bonjour) {
6+
if (!config.devapp) {
77
return;
88
}
99
getProjectJson()
1010
.then(project => project.name)
1111
.catch(() => 'ionic-app-scripts')
1212
.then(projectName => {
13-
Logger.info(`publishing bonjour service`);
13+
try {
14+
const bonjour = require('bonjour')();
15+
const name = projectName + ':' + config.httpPort;
16+
bonjour.publish({
17+
name: name,
18+
type: 'ionicdev',
19+
port: config.httpPort
20+
});
21+
Logger.info(`publishing devapp service (${name})`);
1422

15-
const bonjour = require('bonjour')();
16-
bonjour.publish({
17-
name: projectName,
18-
type: 'ionicdev',
19-
port: config.httpPort
20-
});
21-
22-
const unpublish = function () {
23-
bonjour.unpublishAll();
24-
bonjour.destroy();
25-
};
26-
27-
process.on('exit', unpublish);
28-
process.on('SIGINT', unpublish);
23+
} catch (e) {
24+
Logger.warn('bonjour failed when trying to publish service');
25+
Logger.debug(e);
26+
}
2927
});
3028
}

src/dev-server/serve-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface ServeConfig {
1717
useServerLogs: boolean;
1818
notifyOnConsoleLog: boolean;
1919
useProxy: boolean;
20-
bonjour: boolean;
20+
devapp: boolean;
2121
}
2222
export const LOGGER_DIR = '__ion-dev-server';
2323
export const IONIC_LAB_URL = '/ionic-lab';

src/serve.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('test serve', () => {
3838
useServerLogs: false,
3939
useProxy: true,
4040
notifyOnConsoleLog: false,
41-
bonjour: false
41+
devapp: false
4242
};
4343
spyOn(network, 'findClosestOpenPorts').and.callFake((host: string, ports: number[]) => Promise.resolve(ports));
4444
spyOn(notificationServer, 'createNotificationServer');

src/serve.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function serve(context: BuildContext) {
4747
useServerLogs: useServerLogs(context),
4848
useProxy: useProxy(context),
4949
notifyOnConsoleLog: sendClientConsoleLogs(context),
50-
bonjour: useBonjour(context)
50+
devapp: useBonjour(context)
5151
};
5252

5353
createNotificationServer(config);
@@ -144,7 +144,7 @@ function browserOption(context: BuildContext): string {
144144
}
145145

146146
function useBonjour(context: BuildContext): boolean {
147-
return hasConfigValue(context, '--bonjour', '-B', 'bonjour', false);
147+
return hasConfigValue(context, '--devapp', '-D', 'devapp', false);
148148
}
149149

150150
function launchLab(context: BuildContext): boolean {

0 commit comments

Comments
 (0)