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

Commit 731a307

Browse files
authored
Implement localhost default address for IntelliJ service config
The IntelliJ schema mentions that it defaults to `127.0.0.1:19524` if no address is given. This makes sense as most will connect the service to the IntelliJ instance running on the same host. However the schema requires a value and also the code doesn't check for `undefined` and thus doesn't provide the default if the value is missing. This PR implements the default value by using it if no value is provided and removing `address` from the required fields list of the JSON schema.
1 parent 0958a21 commit 731a307

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

nodecg-io-intellij/extension/index.ts

Lines changed: 2 additions & 3 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,8 +14,7 @@ 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
}

nodecg-io-intellij/extension/intellij.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ export class IntelliJ {
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)