Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 4571bfb

Browse files
authored
Merge pull request #250 from codeoverflow-org/fix/intellij-address-default
Implement `localhost` default address for IntelliJ service config
2 parents 0958a21 + 4e3169b commit 4571bfb

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

nodecg-io-intellij/extension/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Result, emptySuccess, success, ServiceBundle } from "nodecg-io-core";
33
import { IntelliJ } from "./intellij";
44

55
interface IntelliJServiceConfig {
6-
address: string;
6+
address?: string;
77
}
88

99
export type IntelliJServiceClient = IntelliJ;
@@ -14,16 +14,15 @@ module.exports = (nodecg: NodeCG) => {
1414

1515
class IntellijService extends ServiceBundle<IntelliJServiceConfig, IntelliJServiceClient> {
1616
async validateConfig(config: IntelliJServiceConfig): Promise<Result<void>> {
17-
const address = config.address;
18-
const ij = new IntelliJ(address);
17+
const ij = new IntelliJ(config.address);
1918
await ij.rawRequest("available_methods", {});
2019
return emptySuccess();
2120
}
2221

2322
async createClient(config: IntelliJServiceConfig): Promise<Result<IntelliJServiceClient>> {
2423
const ij = new IntelliJ(config.address);
2524
await ij.rawRequest("available_methods", {});
26-
this.nodecg.log.info(`Successfully connected to IntelliJ at ${config.address}.`);
25+
this.nodecg.log.info(`Successfully connected to IntelliJ at ${ij.address}.`);
2726
return success(ij);
2827
}
2928

nodecg-io-intellij/extension/intellij.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import fetch from "node-fetch";
22

33
export class IntelliJ {
4-
private readonly address: string;
4+
readonly address: string;
55

66
readonly pluginManager: PluginManager;
77
readonly localHistory: LocalHistory;
88

9-
public constructor(address: string) {
10-
this.address = address;
11-
if (address.includes("://")) {
9+
constructor(address?: string) {
10+
// Check if protocol is defined and default to http if missing
11+
if (address?.includes("://")) {
1212
this.address = address;
1313
} else {
14-
this.address = "http://" + address;
14+
this.address = `http://${address ?? "127.0.0.1:19524"}`;
1515
}
1616

1717
this.pluginManager = new PluginManager(this);

nodecg-io-intellij/intellij-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"description": "The address where the nodecg-io-intellij server runs. This defaults to 127.0.0.1:19524"
99
}
1010
},
11-
"required": ["address"]
11+
"required": []
1212
}

0 commit comments

Comments
 (0)