Skip to content

Commit

Permalink
fix: empty string $env
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderKoen committed Mar 26, 2024
1 parent 9bea058 commit 3339ce2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ class Executor {

static getEnv(context: TScript): Record<string, string> {
if (typeof context === "string") {
if (context.startsWith("file:")) {
if (context === "") {
return {};
} else if (context.startsWith("file:")) {
// Maybe have an option for static file instead of cws
const file = path.join(process.cwd(), context.slice(5));

Expand Down
20 changes: 20 additions & 0 deletions test/Executor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,26 @@ getEnvSuite("should log error if unknown string", () => {
);
});

getEnvSuite("should return empty if empty string", () => {
// Arrange

// Act
const result = Executor.getEnv("");

// Assert
assert.equal(result, {});
});

getEnvSuite("should not log error if empty string", () => {
// Arrange

// Act
Executor.getEnv("");

// Assert
assert.equal(consoleError.callCount, 0);
});

getEnvSuite.run();
//endregion

Expand Down

0 comments on commit 3339ce2

Please sign in to comment.