Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theplenkov-npm/check
Check CLI
https://github.com/theplenkov-npm/check
Last synced: about 1 month ago
JSON representation
Check CLI
- Host: GitHub
- URL: https://github.com/theplenkov-npm/check
- Owner: theplenkov-npm
- License: mit
- Created: 2022-07-18T07:38:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-18T10:23:35.000Z (over 2 years ago)
- Last Synced: 2024-10-12T14:42:30.771Z (2 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Check Environment Variables (CLI)
This CLI was created having a specific case. I had a script like
```
"prepare":"husky install"
```and I wanted to run it only during non-production install ( because husky was a dev dependency )
So then I thought - it would be nice to check environment variable NODE_ENV which is prefilled with production value in case of using --production flag for npm install
Then I decided to solve this task in a generiс way with this module
## Usage
For the mentioned above problem now my code looks like this:
```
"prepare":"check NODE_ENV=production || husky install"
```So as you see it's a very minimalistic implementation without complicated conditions or OS-dependent if statements but allowing to use any environment variable.
You can also wrap it to another script for reusability. Another trick is to use it via npx - thus you won't need to declare this module as a global depenendcy for your package.```
"prepare": "npm run is-prod || husky install",
"is-prod": "npx -y check-env-cli NODE_ENV=production"
```