Skip to content

Commit 68891a6

Browse files
aduh95targos
authored andcommitted
test: fix test-process-load-env-file when path contains '
If the repo is cloned on a path that contains a quote, the test should not fail. PR-URL: #54511 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 4f82673 commit 68891a6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/parallel/test-process-load-env-file.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { join } = require('node:path');
88

99
const basicValidEnvFilePath = fixtures.path('dotenv/basic-valid.env');
1010
const validEnvFilePath = fixtures.path('dotenv/valid.env');
11-
const missingEnvFile = fixtures.path('dotenv/non-existent-file.env');
11+
const missingEnvFile = fixtures.path('dir%20with unusual"chars \'åß∂ƒ©∆¬…`/non-existent-file.env');
1212

1313
describe('process.loadEnvFile()', () => {
1414

@@ -85,7 +85,11 @@ describe('process.loadEnvFile()', () => {
8585
assert.match(child.stderr, /code: 'ERR_ACCESS_DENIED'/);
8686
assert.match(child.stderr, /permission: 'FileSystemRead'/);
8787
if (!common.isWindows) {
88-
assert(child.stderr.includes(`resource: '${JSON.stringify(missingEnvFile).replaceAll('"', '')}'`));
88+
const resource = /^\s+resource: (['"])(.+)\1$/m.exec(child.stderr);
89+
assert(resource);
90+
assert.strictEqual(resource[2], resource[1] === "'" ?
91+
missingEnvFile.replaceAll("'", "\\'") :
92+
JSON.stringify(missingEnvFile).slice(1, -1));
8993
}
9094
assert.strictEqual(child.code, 1);
9195
});

0 commit comments

Comments
 (0)