std-env 2.0.2 → 2.2.1

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 (2) hide show
  1. package/index.js +27 -16
  2. package/package.json +2 -2
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
- if (process.NODE_ENV) {
21
- nodeENV = String(process.env.NODE_ENV)
33
+ if (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
- module.exports = env
70
+ module.exports = Object.freeze(env)
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "std-env",
3
- "version": "2.0.2",
3
+ "version": "2.2.1",
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",
7
+ "repository": "jsless/std-env",
8
8
  "contributes": [
9
9
  "Pooya Parsa <pooya@pi0.ir>"
10
10
  ],