Skip to content

Commit

Permalink
perf: reduce dependency on process proxy for flags
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 9, 2023
1 parent 058abc6 commit 0d7b84f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/flags.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { detectProvider, ProviderName } from "./providers";
import { env, nodeENV } from "./env";
import { toBoolean } from "./_utils";
import { process } from "./process";
import { _process } from "./process";

/** Value of process.platform */
export const platform = process.platform || "";
export const platform = _process.platform || "";

/** Current provider info */
export const providerInfo = detectProvider(env);
Expand All @@ -14,7 +14,7 @@ export const provider: ProviderName = providerInfo.name;
export const isCI = toBoolean(env.CI) || providerInfo.ci !== false;

/** Detect if stdout.TTY is available */
export const hasTTY = toBoolean(process.stdout && process.stdout.isTTY);
export const hasTTY = toBoolean(_process.stdout && _process.stdout.isTTY);

/** Detect if global `window` object is available */
export const hasWindow = typeof window !== "undefined";
Expand Down
2 changes: 1 addition & 1 deletion src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface Process
versions: Record<string, string>;
}

const _process = (globalThis.process ||
export const _process = (globalThis.process ||
Object.create(null)) as unknown as Process;

const processShims: Partial<Process> = {
Expand Down
1 change: 1 addition & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe("std-env", () => {
"isLinux",
"isMacOS",
"isColorSupported",
"_process",
"process",
"detectProvider",
]
Expand Down

0 comments on commit 0d7b84f

Please sign in to comment.