GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: don't match after `--` in `Dotenv::GetPathFromArgs` · nodejs/node@f87aa27

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_dotenv.cc
  • test/parallel
    • test-dotenv-edge-cases.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_dotenv.cc‎

Copy file name to clipboardExpand all lines: src/node_dotenv.cc
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ using v8::String;
1414
std::vector<std::string> Dotenv::GetPathFromArgs(
1515
const std::vector<std::string>& args) {
1616
const auto find_match = [](const std::string& arg) {
17-
const std::string_view flag = "--env-file";
18-
return strncmp(arg.c_str(), flag.data(), flag.size()) == 0;
17+
return arg == "--" || arg == "--env-file" || arg.starts_with("--env-file=");
1918
};
2019
std::vector<std::string> paths;
2120
auto path = std::find_if(args.begin(), args.end(), find_match);
2221

2322
while (path != args.end()) {
23+
if (*path == "--") {
24+
return paths;
25+
}
2426
auto equal_char = path->find('=');
2527

2628
if (equal_char != std::string::npos) {
Collapse file

‎test/parallel/test-dotenv-edge-cases.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-dotenv-edge-cases.js
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,18 @@ describe('.env supports edge cases', () => {
9898
assert.strictEqual(child.stderr, '');
9999
assert.strictEqual(child.code, 0);
100100
});
101+
102+
it('should handle when --env-file is passed along with --', async () => {
103+
const child = await common.spawnPromisified(
104+
process.execPath,
105+
[
106+
'--eval', `require('assert').strictEqual(process.env.BASIC, undefined);`,
107+
'--', '--env-file', validEnvFilePath,
108+
],
109+
{ cwd: fixtures.path('dotenv') },
110+
);
111+
assert.strictEqual(child.stdout, '');
112+
assert.strictEqual(child.stderr, '');
113+
assert.strictEqual(child.code, 0);
114+
});
101115
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.