Skip to content

Commit

Permalink
fix: Fix detecting project name
Browse files Browse the repository at this point in the history
  • Loading branch information
efirs committed Dec 16, 2022
1 parent d2e6f5e commit 7261e62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/tigris.rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ describe("rpc tests", () => {
});

it("serverMetadata", () => {
const tigris = new Tigris({serverUrl: "localhost:" + SERVER_PORT});
const tigris = new Tigris({serverUrl: "localhost:" + SERVER_PORT, projectName: "db3"});
const serverMetadataPromise = tigris.getServerMetadata();
serverMetadataPromise.then(value => {
expect(value.serverVersion).toBe("1.0.0-test-service");
Expand Down
13 changes: 8 additions & 5 deletions src/tigris.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ export class Tigris {
}
if (config.serverUrl === undefined) {
config.serverUrl = DEFAULT_URL;
if (!("TIGRIS_PROJECT" in process.env)) {
throw new Error("Unable to resolve TIGRIS_PROJECT environment variable");
} else {
config.projectName = process.env.TIGRIS_PROJECT;
}
if (process.env.TIGRIS_URI?.trim().length > 0) {
config.serverUrl = process.env.TIGRIS_URI;
}
Expand All @@ -156,6 +151,14 @@ export class Tigris {
}
}

if (config.projectName === undefined) {
if (!("TIGRIS_PROJECT" in process.env)) {
throw new Error("Unable to resolve TIGRIS_PROJECT environment variable");
}

config.projectName = process.env.TIGRIS_PROJECT;
}

if (config.serverUrl.startsWith("https://")) {
config.serverUrl = config.serverUrl.replace("https://", "");
}
Expand Down

0 comments on commit 7261e62

Please sign in to comment.