xian-ncc-da-client/EnvParse.js
2023-10-17 11:09:53 +08:00

13 lines
368 B
JavaScript

const DotEnv = require('dotenv')
module.exports = function () {
let script = process.env.npm_lifecycle_script;
script = script.substring(script.indexOf("NODE_ENV=") + "NODE_ENV=".length);
let name = script.substring(0,script.indexOf("&"))
console.log(name);
name = ".env." + name
let parsedEnv = DotEnv.config({ path: name }).parsed
return parsedEnv
}