Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorthand for IS_BUILD_MODE #2268

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
IS_BUILDING shorthand
  • Loading branch information
mcgear committed Jan 19, 2024
commit fbbfb4ce7ffe90eaed8df4fe9600b41cb32d0620
1 change: 1 addition & 0 deletions src/server/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type {
export { RenderContext } from "./render.ts";
export type { InnerRenderFunction } from "./render.ts";
export type { DestinationKind } from "./router.ts";
export { IS_BUILDING } from "./utils.ts";

export interface Manifest {
routes: Record<
Expand Down
17 changes: 17 additions & 0 deletions src/server/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Returns true when the current process deno run process is building. This is used to guard build-dependent code.
* Shorthand for the following:
* `Deno.args.includes("build")`
*
* @example
* ```
* if (IS_BUILDING) {
* console.log('This is code run during bulid!');
* } else {
* console.log('This is code run without bulid!');
* }
* ```
*
* Use this to restrict aspects of code from running during ahead of time builds.
*/
export const IS_BUILDING = Deno.args.includes("build");