This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+5
View File
@@ -0,0 +1,5 @@
# Changelog
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.
### [2.3.1](https://github.com/unjs/std-env/compare/v2.3.0...v2.3.1) (2021-09-29)
+22
View File
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2021 UnJS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+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
```
Using 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
+20
View File
@@ -0,0 +1,20 @@
declare const env: {
readonly browser: boolean
readonly test: boolean
readonly dev: boolean
readonly production: boolean
readonly debug: boolean
readonly ci: boolean
readonly tty: boolean
readonly minimal: boolean
readonly minimalCLI: boolean
readonly windows: boolean
readonly darwin: boolean
readonly linux: boolean
};
export default env;
+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)
+61
View File
@@ -0,0 +1,61 @@
{
"_args": [
[
"std-env@2.3.1",
"/home/node/nuxt"
]
],
"_from": "std-env@2.3.1",
"_id": "std-env@2.3.1",
"_inBundle": false,
"_integrity": "sha512-eOsoKTWnr6C8aWrqJJ2KAReXoa7Vn5Ywyw6uCXgA/xDhxPoaIsBa5aNJmISY04dLwXPBnDHW4diGM7Sn5K4R/g==",
"_location": "/std-env",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "std-env@2.3.1",
"name": "std-env",
"escapedName": "std-env",
"rawSpec": "2.3.1",
"saveSpec": null,
"fetchSpec": "2.3.1"
},
"_requiredBy": [
"/@nuxt/cli",
"/@nuxt/config",
"/@nuxt/telemetry",
"/@nuxt/webpack",
"/webpackbar"
],
"_resolved": "https://registry.npmjs.org/std-env/-/std-env-2.3.1.tgz",
"_spec": "2.3.1",
"_where": "/home/node/nuxt",
"bugs": {
"url": "https://github.com/unjs/std-env/issues"
},
"dependencies": {
"ci-info": "^3.1.1"
},
"description": "Detect running environment of the current Node.js process",
"devDependencies": {
"standard-version": "^9.3.1"
},
"files": [
"index.js",
"index.d.ts"
],
"homepage": "https://github.com/unjs/std-env#readme",
"license": "MIT",
"main": "./index.js",
"name": "std-env",
"repository": {
"type": "git",
"url": "git+https://github.com/unjs/std-env.git"
},
"scripts": {
"release": "standard-version && git push --follow-tags && npm publish"
},
"types": "./index.d.ts",
"version": "2.3.1"
}