Skip to content

Commit 24a2adc

Browse files
committed
clearer startup message
- Log url the user should open in browser and make that log message stand out a bit - hide instance started messages unless `NODE_DEBUG` is set closes #73
1 parent 18b50e0 commit 24a2adc

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

backend/instance.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AppInfo } from "./appInfo";
1010
import { getColorForId } from "./color";
1111
import { Instance as FrontendInstance } from "../types/instance";
1212
import { getInstanceUrl } from "./instance_url";
13+
import { env } from "process";
1314

1415
export type Options = {
1516
basePort: number;
@@ -53,7 +54,9 @@ class Instance {
5354

5455
start() {
5556
this.server = this.app.listen(this.port, () => {
56-
console.log(`Starting webxdc instance at port ${this.port}`);
57+
if (env['NODE_DEBUG']) {
58+
console.debug(`Starting webxdc instance at port ${this.port}`);
59+
}
5760
});
5861
}
5962

backend/run.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import detectPort from "detect-port";
2-
import process from "process";
2+
import process, { env } from "process";
33
import open from "open";
44

55
import { createFrontend, InjectExpress } from "./app";
66
import { Instances, Options } from "./instance";
77
import { getLocation, Location, LocationError } from "./location";
88
import { getAppInfo, AppInfo, AppInfoError } from "./appInfo";
9+
import { getInstanceUrl } from "./instance_url";
910

1011
export type Inject = {
1112
injectFrontend: InjectExpress;
@@ -35,12 +36,14 @@ async function actualRun(
3536
);
3637

3738
frontend.listen(options.basePort, () => {
38-
console.log("Starting webxdc-dev frontend");
39+
console.info(`\n=> Started webxdc-dev frontend on ${getInstanceUrl(options.basePort)}`);
3940
});
4041

4142
instances.start();
4243

43-
open("http://localhost:" + options.basePort);
44+
if (!env["CODESPACE_NAME"]) { // do not auto open on gh codespace
45+
open("http://localhost:" + options.basePort);
46+
}
4447
}
4548

4649
export async function run(
@@ -65,7 +68,7 @@ export async function run(
6568
});
6669
}
6770

68-
console.log("Starting webxdc project in:", locationStr);
71+
console.debug("Starting webxdc project in:", locationStr);
6972

7073
try {
7174
const appInfo = await getAppInfo(location);

0 commit comments

Comments
 (0)