Skip to content

Commit

Permalink
fix: avoid error when outputDir is contained in a non-existent direct…
Browse files Browse the repository at this point in the history
…ory (#1647)

#### Details

This PR adds a `{ recursive: true }` option to the point where we create
the `outputDir`, such that it will no longer be an error to specify an
outputDir with an ancestor that doesn't exist yet.

##### Motivation

Addresses #1609 

##### Context

n/a

#### Pull request checklist
<!-- If a checklist item is not applicable to this change, write "n/a"
in the checkbox -->
- [x] Addresses an existing issue: Fixes #1609
- [x] Added relevant unit test for your changes. (`yarn test`)
- [x] Verified code coverage for the changes made. Check coverage report
at: `<rootDir>/test-results/unit/coverage`
- [x] Ran precheckin (`yarn precheckin`)
  • Loading branch information
dbjorge committed Apr 27, 2023
1 parent bd73912 commit ec4ea58
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/shared/src/scanner/scanner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ describe(Scanner, () => {
.returns(() => false)
.verifiable();
// eslint-disable-next-line security/detect-non-literal-fs-filename
fsMock.setup((fsm) => fsm.mkdirSync(reportOutDir)).verifiable();
fsMock.setup((fsm) => fsm.mkdirSync(reportOutDir, { recursive: true })).verifiable();

const crawlerParams: CrawlerRunOptions = {
baseUrl: scanArguments.url,
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/scanner/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class Scanner {
if (!this.fileSystemObj.existsSync(outDirectory)) {
this.logger.logInfo(`Report output directory does not exist. Creating directory ${outDirectory}`);
// eslint-disable-next-line security/detect-non-literal-fs-filename
this.fileSystemObj.mkdirSync(outDirectory);
this.fileSystemObj.mkdirSync(outDirectory, { recursive: true });
}
}

Expand Down

0 comments on commit ec4ea58

Please sign in to comment.