Created
February 9, 2024 15:49
-
-
Save 26medias/fae3ec365c40b8fda0add1b05bc4c01e to your computer and use it in GitHub Desktop.
env to .env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readline = require('readline'); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
let inputData = ''; | |
rl.on('line', (input) => { | |
inputData += input + '\n'; | |
if (input === '' && inputData.endsWith('\n\n')) { | |
const envLines = inputData.trim().split('\n'); | |
const convertedLines = envLines.map(line => { | |
const match = line.match(/"([^"]+)":\s*(.+)/); | |
return match ? `${match[1]}=${match[2]}` : ''; | |
}).filter(line => line); | |
console.log(convertedLines.join('\n')); | |
rl.close(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment