Comments (1)
The current code is not only parsing, but also does variable substitution.
const buffer = stripBOM(fs.readFileSync(envFilePath, 'utf8'));
buffer.split('\n').forEach((line) => {
const r = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/);
if (r !== null) {
let value = r[2] || '';
if (value.length > 0 && value.charAt(0) === '"' && value.charAt(value.length - 1) === '"') {
value = value.replace(/\\n/gm, '\n');
}
const v = value.replace(/(^['"]|['"]$)/g, '');
env[r[1]] = substituteEnvVars(v, env, globalVars!);
}
});
return env;
microsoft/vscode-python extension does env var substitution similarly, and they do not use dotenv
because it loses ordering (1).
dotenv's parse
itself is pretty straightforward (except the complex regexp) and not too many lines of code. How about borrowing the code but modifying it to preserve ordering?
from vscode-go.
Related Issues (20)
- Takes ages to save file on windows
- gopls: automated issue report (crash) HOT 1
- gopls: automated issue report (crash) HOT 1
- debug golang project, breakpoint is invalid HOT 7
- gopls: automated issue report (crash) HOT 2
- gopls: automated issue report (crash) HOT 2
- gopls: automated issue report (crash) HOT 1
- gopls: automated issue report (crash) HOT 3
- Release v0.42.0 HOT 5
- testing: Install Tests using the local fake proxy fail with go1.19/1.20 HOT 2
- gopls: automated issue report (crash) HOT 1
- gopls: automated issue report (crash) HOT 2
- debug: Launch Package template triggered with no config does not match the templates in `package.json`
- gopls: automated issue report (initialization) HOT 1
- Mac 3 silicon VSCode with dev container and golang fails to run debugger on goroutine implementation HOT 2
- gopls: automated issue report (crash) HOT 1
- kokoro CI and build/all.bash testlocal are failing with "sh: 1: esbuild: not found" HOT 1
- bug
- gopls: automated issue report (crash) HOT 3
- gopls: automated issue report (crash) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-go.