Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
- Loading branch information
Showing
10 changed files
with
80 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function isProduction() { | ||
return process.env.NODE_ENV === "production"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import SonicBoom from "sonic-boom"; | ||
|
||
export async function captureLogOutput(action: () => any): Promise<string> { | ||
let outputData = ""; | ||
|
||
const sbWrite = SonicBoom.prototype.write; | ||
SonicBoom.prototype.write = function (data) { | ||
outputData += data; | ||
}; | ||
|
||
try { | ||
await action(); | ||
|
||
return outputData; | ||
} finally { | ||
SonicBoom.prototype.write = sbWrite; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { isProduction } from "../../src/helpers/is-production"; | ||
|
||
describe("isProduction", () => { | ||
it("returns true if the NODE_ENV is set to production", () => { | ||
process.env.NODE_ENV = "production"; | ||
expect(isProduction()).toBe(true); | ||
}); | ||
|
||
it.each([undefined, "dev", "test", ""])( | ||
"returns false if the NODE_ENV is set to %s", | ||
(value) => { | ||
process.env.NODE_ENV = value; | ||
expect(isProduction()).toBe(false); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters