Skip to content

Commit a7894c7

Browse files
authored
clearer startup message (#81)
* 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 * fix fmt
1 parent 1a560d8 commit a7894c7

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

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: 10 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,17 @@ async function actualRun(
3536
);
3637

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

4144
instances.start();
4245

43-
open("http://localhost:" + options.basePort);
46+
if (!env["CODESPACE_NAME"]) {
47+
// do not auto open on gh codespace
48+
open("http://localhost:" + options.basePort);
49+
}
4450
}
4551

4652
export async function run(
@@ -65,7 +71,7 @@ export async function run(
6571
});
6672
}
6773

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

7076
try {
7177
const appInfo = await getAppInfo(location);

0 commit comments

Comments
 (0)