Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: create writeFile destination if necessary #15990

Merged
merged 6 commits into from
Nov 14, 2024

Conversation

servusdei2018
Copy link
Contributor

Summary
This PR introduces a fix for writeFile. The function currently assumes that the directories leading to the specified filePath exist, but this PR ensures that they exist.

Related Issues/PRs
No related issues or PRs.

@servusdei2018 servusdei2018 requested a review from a team as a code owner May 10, 2024 22:29
@servusdei2018 servusdei2018 requested review from connorjclark and removed request for a team May 10, 2024 22:29
@servusdei2018 servusdei2018 changed the title fix(cli/printer.js): ensure writeFile creates filePath directories if they don't exist cli(printer.js): ensure writeFile creates filePath directories if they don't exist May 10, 2024
@servusdei2018 servusdei2018 changed the title cli(printer.js): ensure writeFile creates filePath directories if they don't exist cli: ensure writeFile creates filePath directories if they don't exist May 10, 2024
cli/printer.js Outdated Show resolved Hide resolved
Signed-off-by: Nathanael Bracy <[email protected]>
@adamraine
Copy link
Member

Hmm looks like the "throws for invalid paths" test case is failing because !/#@.json is now a valid path (at least on my mac, and our windows CI job).

This updated test should cover the new logic:

it('throws for invalid paths', () => {
  const path = '//#@.json';
  const report = JSON.stringify(sampleResults);
  return assert.rejects(Printer.write(report, 'html', path));
});

Copy link
Member

@adamraine adamraine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the yarn.lock and package-lock.json changes

@adamraine adamraine changed the title cli: ensure writeFile creates filePath directories if they don't exist cli: create writeFile destination if necessary Nov 14, 2024
@adamraine adamraine merged commit 9acc3ae into GoogleChrome:main Nov 14, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants