Skip to content

Commit a0b9d0e

Browse files
authored
Merge pull request #9 from Telefonica/release
Release v1.0.1
2 parents f5f90e4 + c9e9bcd commit a0b9d0e

File tree

7 files changed

+54
-40
lines changed

7 files changed

+54
-40
lines changed

.github/actions/check-and-comment/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ runs:
4242
steps:
4343
- name: Check SPDX headers
4444
id: check-spdx-headers
45-
uses: Telefonica/check-spdx-headers@v1.0.0
45+
uses: Telefonica/check-spdx-headers@v1.0.1
4646
with:
4747
rules: ${{ inputs.rules }}
4848
ignore: ${{ inputs.ignore }}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
#### Deprecated
1212
#### Removed
1313

14+
## [1.0.1] - 2025-01-17
15+
16+
### Fixed
17+
18+
* fix: Ensure that paths correspond to files before trying to read them
19+
1420
## [1.0.0] - 2025-01-17
1521

1622
### Added

dist/index.js

Lines changed: 20 additions & 17 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.

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@tid-xcut/check-spdx-headers",
33
"description": "Checks that files have the correct SPDX headers",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"author": "Telefónica Innovación Digital",
66
"homepage": "https://github.com/Telefonica/check-spdx-headers",
77
"repository": {

src/lib/Checker.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export class Checker {
123123
copyright: string | string[],
124124
): Promise<string | null> {
125125
this._logger.silly(`Checking file copyright`, { file, copyright });
126+
const stats = await stat(file);
126127

127128
const approvedCopyrights = Array.isArray(copyright)
128129
? copyright
@@ -131,29 +132,33 @@ export class Checker {
131132
if (!approvedCopyrights.length) {
132133
return null;
133134
}
135+
if (stats.isFile()) {
136+
const fileContent = await readFile(file, "utf-8");
134137

135-
const fileContent = await readFile(file, "utf-8");
138+
const spdxCopyright = this._getSPDXHeader(
139+
fileContent,
140+
"FileCopyrightText",
141+
);
136142

137-
const spdxCopyright = this._getSPDXHeader(fileContent, "FileCopyrightText");
143+
if (!spdxCopyright) {
144+
const message = `Does not have a copyright`;
145+
this.logger.debug(`File "${file}" ${message.toLowerCase()}`);
146+
return message;
147+
}
138148

139-
if (!spdxCopyright) {
140-
const message = `Does not have a copyright`;
141-
this.logger.debug(`File "${file}" ${message.toLowerCase()}`);
142-
return message;
143-
}
149+
const matches = approvedCopyrights.some((approvedCopyright) => {
150+
const matcher = new RegExp(`^${approvedCopyright}$`);
151+
if (!matcher.test(spdxCopyright)) {
152+
return false;
153+
}
154+
return true;
155+
});
144156

145-
const matches = approvedCopyrights.some((approvedCopyright) => {
146-
const matcher = new RegExp(`^${approvedCopyright}$`);
147-
if (!matcher.test(spdxCopyright)) {
148-
return false;
157+
if (!matches) {
158+
const message = `Does not have the expected copyright`;
159+
this.logger.debug(`File "${file}" ${message.toLowerCase()}`);
160+
return message;
149161
}
150-
return true;
151-
});
152-
153-
if (!matches) {
154-
const message = `Does not have the expected copyright`;
155-
this.logger.debug(`File "${file}" ${message.toLowerCase()}`);
156-
return message;
157162
}
158163

159164
return null;

0 commit comments

Comments
 (0)