Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export default defineBuildConfig({
rollup: {
emitCJS: true,
esbuild: {
minify: true,
minifySyntax: true,
minifyIdentifiers: true,
},
},
entries: ["src/index"],
Expand Down
4 changes: 2 additions & 2 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export type EnvObject = Record<string, string | undefined>;
const _getEnv = (useShim?: boolean) =>
globalThis.process?.env ||
import.meta.env ||
globalThis.Deno?.env.toObject() ||
/* @__PURE__ */ globalThis.Deno?.env.toObject() ||
globalThis.__env__ ||
(useShim ? _envShim : globalThis);

export const env = new Proxy<EnvObject>(_envShim, {
export const env = /* @__PURE__ */ new Proxy<EnvObject>(_envShim, {
get(_, prop) {
const env = _getEnv();
return env[prop as any] ?? _envShim[prop];
Expand Down
21 changes: 13 additions & 8 deletions src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { toBoolean } from "./_utils";
export const platform = globalThis.process?.platform || "";

/** Detect if `CI` environment variable is set or a provider CI detected */
export const isCI = toBoolean(env.CI) || providerInfo.ci !== false;
export const isCI =
/* @__PURE__ */ toBoolean(env.CI) || providerInfo.ci !== false;

/** Detect if stdout.TTY is available */
export const hasTTY = toBoolean(
export const hasTTY = /* @__PURE__ */ toBoolean(
globalThis.process?.stdout && globalThis.process?.stdout.isTTY,
);

Expand All @@ -18,10 +19,10 @@ export const hasTTY = toBoolean(
export const hasWindow = typeof window !== "undefined";

/** Detect if `DEBUG` environment variable is set */
export const isDebug = toBoolean(env.DEBUG);
export const isDebug = /* @__PURE__ */ toBoolean(env.DEBUG);

/** Detect if `NODE_ENV` environment variable is `test` */
export const isTest = nodeENV === "test" || toBoolean(env.TEST);
export const isTest = nodeENV === "test" || /* @__PURE__ */ toBoolean(env.TEST);

/** Detect if `NODE_ENV` environment variable is `production` */
export const isProduction = nodeENV === "production";
Expand All @@ -30,7 +31,8 @@ export const isProduction = nodeENV === "production";
export const isDevelopment = nodeENV === "dev" || nodeENV === "development";

/** Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable */
export const isMinimal = toBoolean(env.MINIMAL) || isCI || isTest || !hasTTY;
export const isMinimal =
/* @__PURE__ */ toBoolean(env.MINIMAL) || isCI || isTest || !hasTTY;

/** Detect if process.platform is Windows */
export const isWindows = /^win/i.test(platform);
Expand All @@ -43,12 +45,15 @@ export const isMacOS = /^darwin/i.test(platform);

/** Color Support */
export const isColorSupported =
!toBoolean(env.NO_COLOR) &&
(toBoolean(env.FORCE_COLOR) ||
/* @__PURE__ */ !toBoolean(env.NO_COLOR) &&
/* @__PURE__ */ (toBoolean(env.FORCE_COLOR) ||
((hasTTY || isWindows) && env.TERM !== "dumb") ||
isCI);

/** Node.js versions */
export const nodeVersion =
(globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
/* @__PURE__ */ (globalThis.process?.versions?.node || "").replace(
/^v/,
"",
) || null;
export const nodeMajorVersion = Number(nodeVersion?.split(".")[0]) || null;
2 changes: 1 addition & 1 deletion src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const processShims: Partial<Process> = {
versions: {},
};

export const process = new Proxy<Process>(_process, {
export const process = /* @__PURE__ */ new Proxy<Process>(_process, {
get(target, prop: keyof Process) {
if (prop === "env") {
return env;
Expand Down
2 changes: 1 addition & 1 deletion src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ function _detectProvider(): ProviderInfo {
}

/** Current provider info */
export const providerInfo = _detectProvider();
export const providerInfo = /* @__PURE__ */ _detectProvider();
export const provider: ProviderName = providerInfo.name;
2 changes: 1 addition & 1 deletion src/runtimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ function _detectRuntime(): RuntimeInfo | undefined {
}
}

export const runtimeInfo = _detectRuntime();
export const runtimeInfo = /* @__PURE__ */ _detectRuntime();

export const runtime: RuntimeName = runtimeInfo?.name || "";