Skip to content

Commit 7897892

Browse files
committed
fix: Imports and tests
1 parent 6718d32 commit 7897892

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

dist/index.js

Lines changed: 13 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const toolkit = require('@github/dependency-submission-toolkit');
1515
* @param {string} fileName - The name of the file from which the SPDX document was extracted.
1616
* @returns {Object} A manifest object containing the processed package data, including direct and indirect dependencies.
1717
*/
18-
module.exports.getManifestFromSpdxFile = (document, fileName) => {
18+
function getManifestFromSpdxFile(document, fileName) {
1919
core.debug(`getManifestFromSpdxFile processing ${fileName}`);
2020

2121
let manifest = new toolkit.Manifest(document.name, fileName);
@@ -65,7 +65,7 @@ module.exports.getManifestFromSpdxFile = (document, fileName) => {
6565
* @param {string[]} files - An array of file paths pointing to SPDX files.
6666
* @returns {Object[]} An array of manifest objects extracted from the SPDX files.
6767
*/
68-
module.exports.getManifestsFromSpdxFiles = (files) => {
68+
function getManifestsFromSpdxFiles(files) {
6969
core.debug(`Processing ${files.length} files`);
7070
let manifests = [];
7171
files?.forEach(file => {
@@ -81,7 +81,7 @@ module.exports.getManifestsFromSpdxFiles = (files) => {
8181
*
8282
* @returns {string[]} An array of strings representing the paths of files that match the given pattern within the specified path.
8383
*/
84-
module.exports.searchFiles = () => {
84+
function searchFiles() {
8585
let filePath = core.getInput('filePath');
8686
let filePattern = core.getInput('filePattern');
8787

@@ -96,7 +96,7 @@ module.exports.searchFiles = () => {
9696
* @param {string} purl - The package URL to be processed.
9797
* @returns {string} The processed package URL with the necessary characters escaped or unescaped.
9898
*/
99-
module.exports.replaceVersionEscape = (purl) => {
99+
function replaceVersionEscape(purl) {
100100
// Some tools are failing to escape the namespace, so we will escape it to work around that
101101
// @ -> %40
102102
// ^ -> %5E
@@ -110,4 +110,12 @@ module.exports.replaceVersionEscape = (purl) => {
110110
}
111111
}
112112
return purl;
113-
}
113+
}
114+
115+
// Exports
116+
module.exports = {
117+
getManifestFromSpdxFile,
118+
getManifestsFromSpdxFiles,
119+
searchFiles,
120+
replaceVersionEscape
121+
}

lib/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe("replace version escape", () => {
1010
expect(new_purl).toBe("pkg:NPM/%40angular/[email protected]");
1111
packageurl.PackageURL.fromString(new_purl);
1212
});
13-
test("if encoding ha already happened", () => {
13+
test("if encoding has already happened", () => {
1414
const purl = "pkg:npm/es-abstract%401.16.0";
1515

1616
var new_purl = lib.replaceVersionEscape(purl);

0 commit comments

Comments
 (0)