Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
The std-env npm package is designed to help developers easily determine the environment their code is running in. It provides a straightforward way to check if the current environment is development, production, test, or a CI (Continuous Integration) environment. This can be particularly useful for configuring applications differently based on the environment or for including/excluding certain features or outputs based on where the code is running.
Check if the environment is development
This feature allows you to check if your code is running in a development environment. It's useful for enabling debug logs or development-specific features.
const isDev = require('std-env').isDev;
console.log(isDev); // true if in a development environment
Check if the environment is production
This feature enables you to determine if your application is running in a production environment, which is useful for enabling optimizations or features that should only be available in production.
const isProd = require('std-env').isProd;
console.log(isProd); // true if in a production environment
Check if the environment is test
With this feature, you can easily identify if your code is being executed in a test environment, allowing you to adjust configurations or disable certain functionalities during testing.
const isTest = require('std-env').isTest;
console.log(isTest); // true if in a test environment
Check if running in a CI environment
This feature helps in detecting if your application is running in a CI environment, which can be crucial for configuring CI-specific settings or behaviors.
const isCI = require('std-env').isCI;
console.log(isCI); // true if running in a Continuous Integration environment
cross-env allows you to set and use environment variables across platforms. It's similar to std-env in the sense that it helps manage environment-specific settings, but it focuses more on setting environment variables rather than detecting the environment.
dotenv is a package that loads environment variables from a .env file into process.env. While it serves a different purpose by managing environment variables, it complements std-env's functionality by allowing developers to configure their applications based on the detected environment.
Detect current Javascript environment
# Using Yarn
yarn add std-env
# Using npm
npm i std-env
// ESM
import { isWindows } from 'std-env'
// CommonJS
const { isCI } = require('std-env')
Available exports:
hasTTY
hasWindow
isCI
isDebug
isDevelopment
isLinux
isMacOS
isMinimal
isProduction
isTest
isWindows
platform
provider
You can read more about how each flag works from ./src/index.ts.
List of well known providers can be found from ./src/providers.ts.
MIT
v3.3.2
isTest
from NODE_ENV
as well (#39)FAQs
Runtime agnostic JS utils
The npm package std-env receives a total of 6,151,615 weekly downloads. As such, std-env popularity was classified as popular.
We found that std-env demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.