std-env 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +20 -0
  2. package/index.js +25 -14
  3. package/package.json +7 -5
package/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ declare const env: {
2
+ readonly browser: boolean
3
+
4
+ readonly test: boolean
5
+ readonly dev: boolean
6
+ readonly production: boolean
7
+ readonly debug: boolean
8
+
9
+ readonly ci: boolean
10
+ readonly tty: boolean
11
+
12
+ readonly minimal: boolean
13
+ readonly minimalCLI: boolean
14
+
15
+ readonly windows: boolean
16
+ readonly darwin: boolean
17
+ readonly linux: boolean
18
+ };
19
+
20
+ export default env;
package/index.js CHANGED
@@ -5,31 +5,40 @@ var tty = false
5
5
  var nodeENV = 'development'
6
6
  var browser = typeof window !== 'undefined'
7
7
  var platform = ''
8
+ var minimal = false
8
9
 
9
- // Process dependent fields
10
+ // Boolean helper
11
+ function toBoolean(val) {
12
+ return (!val || val === 'false') ? false : true
13
+ }
14
+
15
+ // Process dependent
10
16
  if (typeof process !== 'undefined') {
17
+ // Platform
11
18
  if (process.platform) {
12
19
  platform = String(process.platform)
13
20
  }
14
21
 
15
- if (process.env) {
16
- // isCI
17
- isCI = Boolean(require('ci-info').isCI)
22
+ // TTY
23
+ if (process.stdout) {
24
+ tty = toBoolean(process.stdout.isTTY)
25
+ }
18
26
 
27
+ // Is CI
28
+ isCI = Boolean(require('ci-info').isCI)
29
+
30
+ // Env dependent
31
+ if (process.env) {
19
32
  // NODE_ENV
20
33
  if (process.env.NODE_ENV) {
21
- nodeENV = String(process.env.NODE_ENV)
34
+ nodeENV = process.env.NODE_ENV
22
35
  }
23
36
 
24
37
  // DEBUG
25
- if (process.DEBUG) {
26
- debug = Boolean(process.env.DEBUG)
27
- }
38
+ debug = toBoolean(process.env.DEBUG)
28
39
 
29
- // TTY
30
- if (process.stdout) {
31
- tty = Boolean(process.stdout.isTTY)
32
- }
40
+ // MINIMAL
41
+ minimal = toBoolean(process.env.MINIMAL)
33
42
  }
34
43
  }
35
44
 
@@ -45,6 +54,7 @@ var env = {
45
54
  ci: isCI,
46
55
  tty: tty,
47
56
 
57
+ minimal: undefined,
48
58
  minimalCLI: undefined,
49
59
 
50
60
  windows: /^win/i.test(platform),
@@ -52,8 +62,9 @@ var env = {
52
62
  linux: /^linux/i.test(platform),
53
63
  }
54
64
 
55
- // Compute minimalCLI
56
- env.minimalCLI = env.ci || env.test || env.production || !env.tty
65
+ // Compute minimal
66
+ env.minimal = minimal || env.ci || env.test || !env.tty
67
+ env.minimalCLI = env.minimal
57
68
 
58
69
  // Export env
59
70
  module.exports = Object.freeze(env)
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "std-env",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "Detect running environment of the current Node.js process",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
7
- "repository": "blindmedia/std-env",
8
- "contributes": [
7
+ "types": "index.d.ts",
8
+ "repository": "nuxt-contrib/std-env",
9
+ "contributors": [
9
10
  "Pooya Parsa <pooya@pi0.ir>"
10
11
  ],
11
12
  "dependencies": {
12
- "ci-info": "^1.6.0"
13
+ "ci-info": "^3.0.0"
13
14
  },
14
15
  "files": [
15
- "index.js"
16
+ "index.js",
17
+ "index.d.ts"
16
18
  ]
17
19
  }