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 +5 -0
- package/LICENCE +22 -0
- package/README.md +2 -2
- package/index.d.ts +20 -0
- package/index.js +25 -14
- package/package.json +14 -9
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
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
|
-
//
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 =
|
|
34
|
+
nodeENV = process.env.NODE_ENV
|
|
22
35
|
}
|
|
23
36
|
|
|
24
37
|
// DEBUG
|
|
25
|
-
|
|
26
|
-
debug = Boolean(process.env.DEBUG)
|
|
27
|
-
}
|
|
38
|
+
debug = toBoolean(process.env.DEBUG)
|
|
28
39
|
|
|
29
|
-
//
|
|
30
|
-
|
|
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
|
|
56
|
-
env.
|
|
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.
|
|
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
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
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.
|
|
17
|
+
"ci-info": "^3.1.1"
|
|
13
18
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"standard-version": "^9.3.1"
|
|
21
|
+
}
|
|
17
22
|
}
|