Skip to content

Commit

Permalink
docs: add EnvInfo interface
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 2, 2021
1 parent 764186a commit f75102d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import envInfo from 'std-env'
const envInfo = require('std-env')
```

You can read more about `envInfo` from [./src/types.ts](./src/types.ts)

## License

MIT
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { EnvInfo } from './types'

// Gather initial information
let isCI = false
let debug = false
Expand Down Expand Up @@ -43,7 +45,7 @@ if (typeof process !== 'undefined') {
}

// Construct env object
const env = {
const env: EnvInfo = {
browser: browser,

test: nodeENV === 'test',
Expand All @@ -55,7 +57,6 @@ const env = {
tty: tty,

minimal: undefined,
minimalCLI: undefined,

windows: /^win/i.test(platform),
darwin: /^darwin/i.test(platform),
Expand All @@ -64,7 +65,6 @@ const env = {

// Compute minimal
env.minimal = minimal || env.ci || env.test || !env.tty
env.minimalCLI = env.minimal

// Export env
export default Object.freeze(env)
24 changes: 24 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export interface EnvInfo {
/** Detect if global `window` object is available */
browser: boolean
/** Detect if `NODE_ENV` environment variable is `test` */
test: boolean
/** Detect if `NODE_ENV` environment variable is `dev` or `development` */
dev: boolean
/** Detect if `NODE_ENV` environment variable is `production` */
production: boolean
/** Detect if `DEBUG` environment variable is set */
debug: boolean
/** Detect if a well-known CI is detected */
ci: boolean
/** Detect if TTY is available */
tty: boolean
/** Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable */
minimal: boolean
/** Detect if process.platform is windows */
windows: boolean
/** Detect if process.platform is darwin (MacOS) */
darwin: boolean
/** Detect if process.platform is linux */
linux: boolean
}

0 comments on commit f75102d

Please sign in to comment.