Skip to content

Commit b8d2fd0

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

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/utils/licenseUtility.node.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ interface PathUtils {
3535
join: typeof NATIVE_PATH.join
3636
}
3737

38-
export interface FetchResult {
39-
file: string
38+
export interface FetchedAttachmentResult {
4039
filePath: string
40+
file: string
4141
text: Attachment
4242
}
4343

@@ -60,14 +60,14 @@ export class LicenseEvidenceFetcher {
6060
* @param options.path - If omitted, the native `node:path` is used.
6161
*/
6262
/* eslint-enable tsdoc/syntax */
63-
constructor(options: { fs?: FsUtils, path?: PathUtils } = {}) {
63+
constructor (options: { fs?: FsUtils, path?: PathUtils } = {}) {
6464
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-require-imports -- needed */
6565
this.#fs = options.fs ?? require('node:fs')
6666
this.#path = options.path ?? require('node:path')
6767
/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-require-imports */
6868
}
6969

70-
* fetch(prefixPath: string, onError: ErrorReporter = noop): Generator<FetchResult> {
70+
* fetchAsAttachment (prefixPath: string, onError: ErrorReporter = noop): Generator<FetchedAttachmentResult> {
7171
const files = this.#fs.readdirSync(prefixPath)
7272
for (const file of files) {
7373
if (!LICENSE_FILENAME_PATTERN.test(file)) {
@@ -84,10 +84,7 @@ export class LicenseEvidenceFetcher {
8484
continue
8585
}
8686
try {
87-
yield {
88-
filePath,
89-
file,
90-
text: new Attachment(
87+
yield { filePath, file, text: new Attachment(
9188
this.#fs.readFileSync(filePath).toString('base64'),
9289
{
9390
contentType,

0 commit comments

Comments
 (0)