xian-ncc-da-client/EnvParse.js

13 lines
368 B
JavaScript
Raw Normal View History

2023-10-16 14:01:38 +08:00
const DotEnv = require('dotenv')
module.exports = function () {
2023-10-17 11:09:53 +08:00
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
2023-10-16 14:01:38 +08:00
return parsedEnv
}