require('dotenv').config(); const fs = require('fs'); exports.setEnv = function() { let endpoint = (process.env.TORRENTS_CSV_ENDPOINT) ? process.env.TORRENTS_CSV_ENDPOINT : "http://0.0.0.0:8080"; let env_line = `export const endpoint = '${endpoint}';`; fs.writeFile("src/env.ts", env_line, function (err) { console.log("Wrote src/env.ts:"); console.log("\t" + env_line); }); }