Skip to content

Commit

Permalink
test: fix test-process-load-env-file when path contains '
Browse files Browse the repository at this point in the history
If the repo is cloned on a path that contains a quote, the test should
not fail.

PR-URL: #54511
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
aduh95 authored and targos committed Oct 2, 2024
1 parent 4f82673 commit 68891a6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/parallel/test-process-load-env-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { join } = require('node:path');

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

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

Expand Down Expand Up @@ -85,7 +85,11 @@ describe('process.loadEnvFile()', () => {
assert.match(child.stderr, /code: 'ERR_ACCESS_DENIED'/);
assert.match(child.stderr, /permission: 'FileSystemRead'/);
if (!common.isWindows) {
assert(child.stderr.includes(`resource: '${JSON.stringify(missingEnvFile).replaceAll('"', '')}'`));
const resource = /^\s+resource: (['"])(.+)\1$/m.exec(child.stderr);
assert(resource);
assert.strictEqual(resource[2], resource[1] === "'" ?
missingEnvFile.replaceAll("'", "\\'") :
JSON.stringify(missingEnvFile).slice(1, -1));
}
assert.strictEqual(child.code, 1);
});
Expand Down

0 comments on commit 68891a6

Please sign in to comment.