Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dotenvx/dotenvx

Package Overview
Dependencies
Maintainers
2
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotenvx/dotenvx - npm Package Compare versions

Comparing version 1.16.1 to 1.17.0

src/lib/helpers/escape.js

8

CHANGELOG.md

@@ -5,4 +5,10 @@ # Changelog

## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.16.1...main)
## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.17.0...main)
## 1.17.0
### Added
* add `--format=eval` option for `get` ([#393](https://github.com/dotenvx/dotenvx/pull/393))
## 1.16.1

@@ -9,0 +15,0 @@

2

package.json
{
"version": "1.16.1",
"version": "1.17.0",
"name": "@dotenvx/dotenvx",

@@ -4,0 +4,0 @@ "description": "a better dotenv–from the creator of `dotenv`",

@@ -1075,2 +1075,29 @@ [![dotenvx](https://dotenvx.com/better-banner.png)](https://dotenvx.com)

</details>
* <details><summary>`get --format eval`</summary><br>
Return an `eval`-ready shell formatted response of all key/value pairs in a `.env` file.
```sh
$ echo "HELLO=World" > .env
$ echo "KEY=value" >> .env
$ dotenvx get --format eval
HELLO="World"
KEY="value"
```
Note that this exports newlines and quoted strings.
This can be useful for more complex .env values (spaces, escaped characters, quotes, etc) combined with `eval` on the command line.
```
$ echo "console.log('Hello ' + process.env.KEY + ' ' + process.env.HELLO)" > index.js
$ eval $(dotenvx get --format=eval) node index.js
Hello value World
```
Be careful with `eval` as it allows for arbitrary execution of commands. Prefer `dotenvx run --` but in some cases `eval` is a sharp knife that is useful to have.
</details>
* <details><summary>`get --all`</summary><br>

@@ -1077,0 +1104,0 @@

const { logger } = require('./../../shared/logger')
const conventions = require('./../../lib/helpers/conventions')
const escape = require('./../../lib/helpers/escape')

@@ -26,6 +27,13 @@ const main = require('./../../lib/main')

if (typeof results === 'object' && results !== null) {
// inline shell format - env $(dotenvx get --format shell) your-command
if (options.format === 'shell') {
if (options.format === 'eval') {
let inline = ''
for (const [key, value] of Object.entries(results)) {
inline += `${key}=${escape(value)}\n`
}
inline = inline.trim()
console.log(inline)
} else if (options.format === 'shell') {
let inline = ''
for (const [key, value] of Object.entries(results)) {
inline += `${key}=${value} `

@@ -36,3 +44,2 @@ }

console.log(inline)
// json format
} else {

@@ -39,0 +46,0 @@ let space = 0

@@ -78,3 +78,3 @@ #!/usr/bin/env node

.option('-pp, --pretty-print', 'pretty print output')
.option('--format <type>', 'format of the output (json, shell)', 'json')
.option('--format <type>', 'format of the output (json, shell, eval)', 'json')
.action(function (...args) {

@@ -81,0 +81,0 @@ this.envs = envs

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc