| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6aa1d9e commit f87aa27
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,13 +14,15 @@ using v8::String; | |||
| 14 | 14 | std::vector<std::string> Dotenv::GetPathFromArgs( | |
| 15 | 15 | const std::vector<std::string>& args) { | |
| 16 | 16 | 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="); | ||
| 19 | 18 | }; | |
| 20 | 19 | std::vector<std::string> paths; | |
| 21 | 20 | auto path = std::find_if(args.begin(), args.end(), find_match); | |
| 22 | 21 | ||
| 23 | 22 | while (path != args.end()) { | |
| 23 | + if (*path == "--") { | ||
| 24 | + return paths; | ||
| 25 | + } | ||
| 24 | 26 | auto equal_char = path->find('='); | |
| 25 | 27 | ||
| 26 | 28 | if (equal_char != std::string::npos) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,4 +98,18 @@ describe('.env supports edge cases', () => { | |||
| 98 | 98 | assert.strictEqual(child.stderr, ''); | |
| 99 | 99 | assert.strictEqual(child.code, 0); | |
| 100 | 100 | }); | |
| 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 | + }); | ||
| 101 | 115 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments