Skip to content

Commit 110fb06

Browse files
committed
feat: license file gathering
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent d754f77 commit 110fb06

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/utils/licenseUtility.node.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class LicenseEvidenceFetcher {
6868
}
6969

7070
* fetchAsAttachment (prefixPath: string, onError: ErrorReporter = noop): Generator<FetchedAttachmentResult> {
71-
const files = this.#fs.readdirSync(prefixPath)
71+
const files = this.#fs.readdirSync(prefixPath) // may throw
7272
for (const file of files) {
7373
if (!LICENSE_FILENAME_PATTERN.test(file)) {
7474
continue
@@ -85,17 +85,11 @@ export class LicenseEvidenceFetcher {
8585
}
8686
try {
8787
yield { filePath, file, text: new Attachment(
88-
this.#fs.readFileSync(filePath).toString('base64'),
89-
{
90-
contentType,
91-
encoding: AttachmentEncoding.Base64
92-
}
93-
)
94-
}
95-
}
96-
/* c8 ignore next 3 */
97-
catch (e) {
98-
onError(new Error(`skipped license file ${filePath}`, {cause: e}))
88+
this.#fs.readFileSync(filePath).toString('base64'), // may throw
89+
{ contentType, encoding: AttachmentEncoding.Base64 }
90+
) }
91+
} catch (cause) {
92+
onError(new Error(`skipped license file ${filePath}`, {cause}))
9993
}
10094
}
10195
}

tests/unit/_helpers.mime.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const assert = require('node:assert')
2121

2222
const { suite, test } = require('mocha')
2323

24-
2524
const {
2625
getMimeForLicenseFile
2726
} = require('../../dist.node/_helpers/mime.js')

0 commit comments

Comments
 (0)