
Security News
NIST Under Federal Audit for NVD Processing Backlog and Delays
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
A simple template processor that replaces environment variables in files with support for arrays and default values
Because your environment variables won't replace themselves.
If you could handle environment templating on your own, you wouldn't be here. But let's not kid ourselves. You're reading this because at some point a ${SECRET}
in your config file made a fool of you. It's okay—no, actually it's not—but I'm feeling generous today.
Meet envtemp, the CLI tool that does the one thing you apparently couldn't: replace those damn placeholders with real values. It grabs your environment variables and injects them into your template file like a cold dose of reality. No whining, no hand-holding. And it doesn't even ask you to install it first. envtemp won't judge you; that's my job.
You want to try it, but commitment issues? Figures. With envtemp, you don't need to install anything. Go ahead, run it with npx
and watch it appear out of nowhere, do your bidding, and vanish without a trace.
No setup, no global clutter – just one command:
npx envtemp input.template output.file
It executes directly from the npm registry, fresh every time, like a hitman who never sticks around. You have zero excuses left. If Node.js is on your machine (and it better be), you're ready to roll.
envtemp is brutally straightforward, which is probably why you didn't think of it:
${VAR}
placeholders).VAR
in your environment:
${VAR:default}
), envtemp grudgingly uses that default.That's it. No magic, no pity. Just your file, now with actual values instead of fantasies.
Maybe you need a demonstration (of course you do). Suppose you have a template file config.template
:
API_URL=${API_URL}
MODE=${MODE:development}
And let's say your environment has API_URL
set to https://api.example.com
but no MODE
variable. Run envtemp:
$ npx envtemp config.template config.txt
After envtemp does its thing, config.txt
will contain:
API_URL=https://api.example.com
MODE=development
Notice how it filled in API_URL
with the real value from your environment (hope it was the right one), and it quietly used "development" for MODE
because you didn't set it. Did you notice how envtemp didn't scream or throw an error? It just did what needed to be done. Efficient – like it should be.
npx envtemp
your templates so deployments have real credentials and endpoints. No more last-minute oops commits.npx
whenever you need. It won't clutter your system or stick around longer than necessary.${VAR}
placeholders in text. Supports default values with ${VAR:default}
for when you inevitably forget to set something.You've made it this far. Now you know exactly what envtemp can do, and exactly which excuses you no longer have. The next time you're tempted to manually fiddle with config placeholders, remember this moment.
Go ahead, walk away if you want. Pretend you don't need envtemp. But when your next deployment goes up in flames because of one stupid missing variable, you'll know where to find it. envtemp will be here, quietly waiting in the dark – ready to help you clean up the mess... if you deserve a second chance.
Consider yourself warned.
SITE_NAME="Site name" KEYWORDS='["keyword1", "keyword2"]' OTHER_VARIABLE="3123" npx envtemp config.toml.template config.toml
The package will replace all occurrences of ${VARIABLE_NAME}
or ${VARIABLE_NAME:default_value}
in the template file with the corresponding environment variable value.
${VARIABLE:default_value}
Template file (config.toml.template
):
site_name = "${SITE_NAME:Default Site Name}"
keywords = "${KEYWORDS:default keyword}"
other_variable = "${OTHER_VARIABLE:42}"
Template file (config.toml.template
):
keywords = "${KEYWORDS:["seo", "template", "default"]}"
authors = "${AUTHORS:["John Doe", "Jane Smith"]}"
config = {
tags = ${TAGS:["web", "docs"]}
ports = ${PORTS:[8080, 3000]}
}
Usage:
KEYWORDS='["react", "node", "typescript"]' PORTS='[3000, 8080, 9000]' npx envtemp config.toml.template config.toml
ISC
FAQs
A simple template processor that replaces environment variables in files with support for arrays, default values, and special date variables
The npm package envtemp receives a total of 7 weekly downloads. As such, envtemp popularity was classified as not popular.
We found that envtemp 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
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.
Security News
TypeScript Native Previews offers a 10x faster Go-based compiler, now available on npm for public testing with early editor and language support.