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

convert-json-env

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convert-json-env - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

example-firebaseConfig.env

21

index.js

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

\t--suffix\tThe suffix of environment variables in env file.
\t--embed\tThe suffix of environment variables in env file.
`

@@ -32,3 +33,3 @@

if (!args._.length) {
if (!inputFile) {
console.log('Invalid usage. Try `convert-json-env --help` for help.');

@@ -46,6 +47,14 @@ return;

const st = Object.keys(data)
.map(k => `${prefix}${k}${suffix}='${data[k]}'`)
.join('\n');
fs.writeFileSync(outputFile, st);
console.log(`✅ ${outputFile} created.`)
if (args.embed) {
const embed =
Object.keys(data).map(k => `${k}: ${prefix}${k}${suffix}`).join(',\n ');
console.log(`{
${embed}
}`)
} else {
const envdata = Object.keys(data)
.map(k => `${prefix}${k}${suffix}='${data[k]}'`)
.join('\n');
fs.writeFileSync(outputFile, envdata);
console.log(`✅ ${outputFile} created.`)
}
{
"name": "convert-json-env",
"version": "1.0.3",
"version": "1.1.0",
"description": "A CLI tool for converting JSON to env file.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -34,4 +34,5 @@ # convert-json-env

### Case 1. Export environment variables.
```sh
$convert-json-env example-firebaseConfig.json --prefix="export "
$ convert-json-env example-firebaseConfig.json --prefix="export "
✅ example-firebaseConfig.env created.

@@ -49,4 +50,5 @@

### Case 2. Environment variables in Vue application.
```sh
$convert-json-env example-firebaseConfig.json --out=.local.env --prefix=VUE_APP_
$ convert-json-env example-firebaseConfig.json --out=.local.env --prefix=VUE_APP_
✅ .local.env created.

@@ -62,4 +64,19 @@

VUE_APP_appId='1:234567890124:web:1234567890abcdef'
```````
```
### Case 3. Standard output for code embedded in javascript.
In this case, no files are output.
```sh
$ convert-json-env example-firebaseConfig.json --prefix=VUE_APP_ --embed
{
apiKey: VUE_APP_apiKey,
authDomain: VUE_APP_authDomain,
databaseURL: VUE_APP_databaseURL,
projectId: VUE_APP_projectId,
storageBucket: VUE_APP_storageBucket,
messagingSenderId: VUE_APP_messagingSenderId,
appId: VUE_APP_appId
}
```
## All CLI Options

@@ -66,0 +83,0 @@

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