cross-env-test is a command-line utility designed to provide a cross-platform method for checking environment variable values within npm scripts or CI/CD pipelines. It allows users to test if a specified environment variable is set to a particular value, exiting with a `0` (success) status code if the condition is met, and a non-zero (failure) code otherwise. This enables conditional execution of scripts, for example, running a build step only when not in a test environment. The current stable version is 0.1.1. Due to its minimal scope and stable functionality, it typically experiences an infrequent release cadence. Its key differentiator is simplifying cross-platform environment variable checks without requiring complex shell-specific logic or full JavaScript execution for simple comparisons, making npm scripts more robust across Windows, macOS, and Linux.
npm install cross-env-testNo compatibility data collected yet for this library.
Demonstrates using `cross-env-test` in npm scripts for conditional command execution. The `postinstall` script runs `npm run build` only if `NODE_ENV` is NOT 'testing'. The `test:e2e` script shows how to check if `CI` is not 'true'.
For more complex comparisons, consider using a dedicated JavaScript file executed via `node -e '...'` or a full scripting language.
Always format arguments as `ENV_VAR=VALUE` or `ENV_VAR!=VALUE`.
If OR logic is required, you might need to use multiple `cross-env-test` calls with shell `||` operators or revert to platform-specific scripting.
Ensure all arguments passed to `cross-env-test` adhere strictly to the expected `KEY=VALUE` or `KEY!=VALUE` format.
Install it as a dev dependency (`npm install --save-dev cross-env-test`) and ensure it's used within npm scripts or via `npx cross-env-test`.
Ensure arguments are in the format `NODE_ENV=testing` or `NODE_ENV!=development`.
Check the condition you are testing. If you intended for the script to fail when the condition isn't met, this is correct. If you expected success, verify the environment variable's actual value or the comparison string.
No dependency data recorded yet.