std-env 2.1.1 → 2.3.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [2.3.1](https://github.com/unjs/std-env/compare/v2.3.0...v2.3.1) (2021-09-29)
package/LICENCE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 UnJS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md CHANGED
@@ -7,13 +7,13 @@ Detect running environment of the current Node.js process.
7
7
 
8
8
  ## Installation
9
9
 
10
- Using yarn:
10
+ Using Yarn:
11
11
 
12
12
  ```
13
13
  yarn add std-env
14
14
  ```
15
15
 
16
- Usin npm:
16
+ Using npm:
17
17
 
18
18
  ```
19
19
  npm i std-env
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.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,22 @@
1
1
  {
2
2
  "name": "std-env",
3
- "version": "2.1.1",
3
+ "version": "2.3.1",
4
4
  "description": "Detect running environment of the current Node.js process",
5
+ "repository": "unjs/std-env",
5
6
  "license": "MIT",
6
- "main": "index.js",
7
- "repository": "blindmedia/std-env",
8
- "contributes": [
9
- "Pooya Parsa <pooya@pi0.ir>"
7
+ "main": "./index.js",
8
+ "types": "./index.d.ts",
9
+ "scripts": {
10
+ "release": "standard-version && git push --follow-tags && npm publish"
11
+ },
12
+ "files": [
13
+ "index.js",
14
+ "index.d.ts"
10
15
  ],
11
16
  "dependencies": {
12
- "ci-info": "^1.6.0"
17
+ "ci-info": "^3.1.1"
13
18
  },
14
- "files": [
15
- "index.js"
16
- ]
19
+ "devDependencies": {
20
+ "standard-version": "^9.3.1"
21
+ }
17
22
  }