|
1 | | -import { providerInfo } from "./providers"; |
2 | | -import { env, nodeENV } from "./env"; |
3 | | -import { toBoolean } from "./_utils"; |
| 1 | +import { providerInfo } from "./providers.ts"; |
| 2 | +import { env, nodeENV } from "./env.ts"; |
| 3 | +import { toBoolean } from "./_utils.ts"; |
4 | 4 |
|
5 | 5 | /** Value of process.platform */ |
6 | | -export const platform = globalThis.process?.platform || ""; |
| 6 | +export const platform: string = globalThis.process?.platform || ""; |
7 | 7 |
|
8 | 8 | /** Detect if `CI` environment variable is set or a provider CI detected */ |
9 | | -export const isCI = toBoolean(env.CI) || providerInfo.ci !== false; |
| 9 | +export const isCI: boolean = toBoolean(env.CI) || providerInfo.ci !== false; |
10 | 10 |
|
11 | 11 | /** Detect if stdout.TTY is available */ |
12 | | -export const hasTTY = toBoolean( |
| 12 | +export const hasTTY: boolean = toBoolean( |
13 | 13 | globalThis.process?.stdout && globalThis.process?.stdout.isTTY, |
14 | 14 | ); |
15 | 15 |
|
16 | 16 | /** Detect if global `window` object is available */ |
17 | 17 | // eslint-disable-next-line unicorn/prefer-global-this |
18 | | -export const hasWindow = typeof window !== "undefined"; |
| 18 | +export const hasWindow: boolean = typeof window !== "undefined"; |
19 | 19 |
|
20 | 20 | /** Detect if `DEBUG` environment variable is set */ |
21 | | -export const isDebug = toBoolean(env.DEBUG); |
| 21 | +export const isDebug: boolean = toBoolean(env.DEBUG); |
22 | 22 |
|
23 | 23 | /** Detect if `NODE_ENV` environment variable is `test` */ |
24 | | -export const isTest = nodeENV === "test" || toBoolean(env.TEST); |
| 24 | +export const isTest: boolean = nodeENV === "test" || toBoolean(env.TEST); |
25 | 25 |
|
26 | 26 | /** Detect if `NODE_ENV` environment variable is `production` */ |
27 | | -export const isProduction = nodeENV === "production"; |
| 27 | +export const isProduction: boolean = nodeENV === "production"; |
28 | 28 |
|
29 | 29 | /** Detect if `NODE_ENV` environment variable is `dev` or `development` */ |
30 | | -export const isDevelopment = nodeENV === "dev" || nodeENV === "development"; |
| 30 | +export const isDevelopment: boolean = |
| 31 | + nodeENV === "dev" || nodeENV === "development"; |
31 | 32 |
|
32 | 33 | /** Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable */ |
33 | | -export const isMinimal = toBoolean(env.MINIMAL) || isCI || isTest || !hasTTY; |
| 34 | +export const isMinimal: boolean = |
| 35 | + toBoolean(env.MINIMAL) || isCI || isTest || !hasTTY; |
34 | 36 |
|
35 | 37 | /** Detect if process.platform is Windows */ |
36 | | -export const isWindows = /^win/i.test(platform); |
| 38 | +export const isWindows: boolean = /^win/i.test(platform); |
37 | 39 |
|
38 | 40 | /** Detect if process.platform is Linux */ |
39 | | -export const isLinux = /^linux/i.test(platform); |
| 41 | +export const isLinux: boolean = /^linux/i.test(platform); |
40 | 42 |
|
41 | 43 | /** Detect if process.platform is macOS (darwin kernel) */ |
42 | | -export const isMacOS = /^darwin/i.test(platform); |
| 44 | +export const isMacOS: boolean = /^darwin/i.test(platform); |
43 | 45 |
|
44 | 46 | /** Color Support */ |
45 | | -export const isColorSupported = |
| 47 | +export const isColorSupported: boolean = |
46 | 48 | !toBoolean(env.NO_COLOR) && |
47 | 49 | (toBoolean(env.FORCE_COLOR) || |
48 | 50 | ((hasTTY || isWindows) && env.TERM !== "dumb") || |
49 | 51 | isCI); |
50 | 52 |
|
51 | 53 | /** Node.js versions */ |
52 | | -export const nodeVersion = |
| 54 | +export const nodeVersion: string | null = |
53 | 55 | (globalThis.process?.versions?.node || "").replace(/^v/, "") || null; |
54 | | -export const nodeMajorVersion = Number(nodeVersion?.split(".")[0]) || null; |
| 56 | + |
| 57 | +export const nodeMajorVersion: number | null = |
| 58 | + Number(nodeVersion?.split(".")[0]) || null; |
0 commit comments