Skip to content

Commit

Permalink
tools: fix lint and format issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustinMauroy committed Jan 26, 2025
1 parent 4ca51e8 commit 8dd566f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/node_dotenv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ void Dotenv::ParseContent(const std::string_view input) {
auto newline = content.find('\n');

// If there is no equal character in this line, skip to next line
if (equal == std::string_view::npos || (newline != std::string_view::npos && equal > newline)) {
if (equal == std::string_view::npos ||
(newline != std::string_view::npos && equal > newline)) {
if (newline != std::string_view::npos) {
content.remove_prefix(newline + 1);
content = trim_spaces(content);
Expand Down
22 changes: 10 additions & 12 deletions test/parallel/test-dotenv-invalid-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ ANOTHER_VALID=value`;

const result = parseEnv(input);

// Using individual assertions for better error messages
assert.strictEqual(Object.keys(result).length, 3, 'Should only have 3 valid entries');
assert.strictEqual(result.baz, 'whatever', 'baz should have value "whatever"');
assert.strictEqual(result.VALID_AFTER_INVALID, 'test', 'VALID_AFTER_INVALID should have value "test"');
assert.strictEqual(result.ANOTHER_VALID, 'value', 'ANOTHER_VALID should have value "value"');
assert.strictEqual(Object.keys(result).length, 3);
assert.strictEqual(result.baz, 'whatever');
assert.strictEqual(result.VALID_AFTER_INVALID, 'test');
assert.strictEqual(result.ANOTHER_VALID, 'value');

// Ensure invalid entries are not present
assert.strictEqual(result.foo, undefined, 'foo should not be present');
assert.strictEqual(result.bar, undefined, 'bar should not be present');
assert.strictEqual(result.multiple_invalid, undefined, 'multiple_invalid should not be present');
assert.strictEqual(result.lines_without_equals, undefined, 'lines_without_equals should not be present');
assert.strictEqual(result.foo, undefined);
assert.strictEqual(result.bar, undefined);
assert.strictEqual(result.multiple_invalid, undefined);
assert.strictEqual(result.lines_without_equals, undefined);
}

// Test edge cases
Expand Down Expand Up @@ -58,14 +57,13 @@ ANOTHER_VALID=value`;
expected: {
VALID: 'value'
}
}
},
];

for (const { input, expected } of edgeCases) {
assert.deepStrictEqual(
parseEnv(input),
expected,
`Failed parsing: ${JSON.stringify(input)}`
expected
);
}
}

0 comments on commit 8dd566f

Please sign in to comment.