This commit is contained in:
darenhsu
2022-07-17 13:16:16 +08:00
parent 84759556ff
commit befd344ab0
28070 changed files with 4008428 additions and 1 deletions
+48
View File
@@ -0,0 +1,48 @@
# std-env
[![npm](https://img.shields.io/npm/dt/std-env.svg?style=flat-square)](http://npmjs.com/package/std-env)
[![npm](https://img.shields.io/npm/v/std-env.svg?style=flat-square)](http://npmjs.com/package/std-env)
Detect running environment of the current Node.js process.
## Installation
Using yarn:
```
yarn add std-env
```
Usin npm:
```
npm i std-env
```
## Usage
```js
const env = require('std-env')
console.log(env)
/*
{
browser: false,
test: false,
dev: true,
production: false,
debug: false,
ci: false,
tty: true,
minimalCLI: false,
windows: false,
darwin: true,
linux: false
}
*/
```
## License
MIT
+70
View File
@@ -0,0 +1,70 @@
// Gather initial information
var isCI = false
var debug = false
var tty = false
var nodeENV = 'development'
var browser = typeof window !== 'undefined'
var platform = ''
var minimal = false
// Boolean helper
function toBoolean(val) {
return (!val || val === 'false') ? false : true
}
// Process dependent
if (typeof process !== 'undefined') {
// Platform
if (process.platform) {
platform = String(process.platform)
}
// TTY
if (process.stdout) {
tty = toBoolean(process.stdout.isTTY)
}
// Is CI
isCI = Boolean(require('ci-info').isCI)
// Env dependent
if (process.env) {
// NODE_ENV
if (process.env.NODE_ENV) {
nodeENV = process.env.NODE_ENV
}
// DEBUG
debug = toBoolean(process.env.DEBUG)
// MINIMAL
minimal = toBoolean(process.env.MINIMAL)
}
}
// Construct env object
var env = {
browser: browser,
test: nodeENV === 'test',
dev: nodeENV === 'development' || nodeENV === 'dev',
production: nodeENV === 'production',
debug: debug,
ci: isCI,
tty: tty,
minimal: undefined,
minimalCLI: undefined,
windows: /^win/i.test(platform),
darwin: /^darwin/i.test(platform),
linux: /^linux/i.test(platform),
}
// Compute minimal
env.minimal = minimal || env.ci || env.test || !env.tty
env.minimalCLI = env.minimal
// Export env
module.exports = Object.freeze(env)
+57
View File
@@ -0,0 +1,57 @@
{
"_args": [
[
"std-env@2.2.1",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
]
],
"_from": "std-env@2.2.1",
"_id": "std-env@2.2.1",
"_inBundle": false,
"_integrity": "sha512-IjYQUinA3lg5re/YMlwlfhqNRTzMZMqE+pezevdcTaHceqx8ngEi1alX9nNCk9Sc81fy1fLDeQoaCzeiW1yBOQ==",
"_location": "/std-env",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "std-env@2.2.1",
"name": "std-env",
"escapedName": "std-env",
"rawSpec": "2.2.1",
"saveSpec": null,
"fetchSpec": "2.2.1"
},
"_requiredBy": [
"/@nuxt/cli",
"/@nuxt/config",
"/@nuxt/core",
"/@nuxt/telemetry",
"/@nuxt/webpack",
"/webpackbar"
],
"_resolved": "https://registry.npmjs.org/std-env/-/std-env-2.2.1.tgz",
"_spec": "2.2.1",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"bugs": {
"url": "https://github.com/jsless/std-env/issues"
},
"contributes": [
"Pooya Parsa <pooya@pi0.ir>"
],
"dependencies": {
"ci-info": "^1.6.0"
},
"description": "Detect running environment of the current Node.js process",
"files": [
"index.js"
],
"homepage": "https://github.com/jsless/std-env#readme",
"license": "MIT",
"main": "index.js",
"name": "std-env",
"repository": {
"type": "git",
"url": "git+https://github.com/jsless/std-env.git"
},
"version": "2.2.1"
}