Skip to content

Commit 3ec62c7

Browse files
committed
feat
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 9a94456 commit 3ec62c7

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/builders/fromPath.node.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,31 @@ export class LicenseEvidenceBuilder {
4444

4545
/**
4646
* Return a license on success, returns undefined if it appears to bes no known text file.
47-
* Throws errors, if license attachment failed to create.
47+
* Throws error, if license attachment content could not be fetched.
4848
*
4949
* @param file - path to file
5050
* @param relativeFrom - path the file shall be relative to
5151
* @returns {@link NamedLicense} on success
5252
*/
5353
public fromFile(file: string, relativeFrom: string | undefined = undefined): NamedLicense | undefined {
54-
let lname
54+
let name
5555
if ( relativeFrom === undefined) {
56-
lname = `file: ${file}`
56+
name = `file: ${file}`
5757
} else {
5858
// `file` could be absolute or relative path - lets resolve it anyway
5959
file = resolve(relativeFrom, file)
60-
lname = `file: ${relative(relativeFrom, file)}`
60+
name = `file: ${relative(relativeFrom, file)}`
6161
}
6262
const text = this.#afac.fromTextFile(file)
6363
if (text === undefined) {
6464
return undefined
6565
}
66-
return new NamedLicense(lname, {text})
66+
return new NamedLicense(name, {text})
6767
}
6868

6969
/**
7070
* Returns a generator for license evidences.
71-
* Throws errors, if dir cannot be inspected.
71+
* Throws error, if dir content could not be inspected.
7272
*
7373
* @param dir - path to inspect
7474
* @param relativeFrom - path the dir and files shall be relative to

src/factories/fromPath.node.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ import {Attachment} from "../models/attachment";
3434
*/
3535
export class AttachmentFactory {
3636

37+
/**
38+
* Return an attachment on success.
39+
* Throws error, if content could not be fetched.
40+
*
41+
* @returns {@link NamedLicense} on success
42+
*/
3743
public fromFile(file: string, contentType: MimeType): Attachment {
3844
return new Attachment(
3945
// may throw if `readFileSync()` fails
@@ -44,6 +50,12 @@ export class AttachmentFactory {
4450
})
4551
}
4652

53+
/**
54+
* Return an attachment on success, returns undefined if it appears to bes no known text file.
55+
* Throws error, if content could not be fetched.
56+
*
57+
* @returns {@link Attachment} on success
58+
*/
4759
public fromTextFile(file: string): Attachment | undefined {
4860
const contentType = getMimeTypeForTextFile(file)
4961
if (contentType === undefined) {

0 commit comments

Comments
 (0)