UNPKG

envfile

Version:

Parse and stringify the environment configuration files and format, also known as .env files and dotenv files

23 lines (22 loc) 708 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // builtin const process_1 = require("process"); // local const index_js_1 = require("./index.js"); // are we wanting to convert from json to env? const jsonToEnv = process_1.argv.slice(1).join(' ').includes('json2env'); // get the data let data = ''; process_1.stdin.on('readable', function () { const chunk = process_1.stdin.read(); if (chunk) data += chunk.toString(); }); // do the conversion process_1.stdin.on('end', function () { const result = jsonToEnv ? (0, index_js_1.stringify)(JSON.parse(data)) : JSON.stringify((0, index_js_1.parse)(data)); process_1.stdout.write(result); });