Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit fbcd652

Browse files
author
Cdok
committed
address PR feedback - stylistic fixes
This commit removes the .txt file extensions, as well as renaming the filesMissingHeader variable. Additionally, refactors the check for "hasCopyrightHeader"
1 parent 8d2557d commit fbcd652

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

β€Žcopyright/copyright.jsβ€Ž

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ const copyright = {
3333
})
3434

3535
Promise.all(processedGlobs).then((files) => {
36-
const filesMissingHeader = files.filter((file) => {
37-
const content = fs.readFileSync(file)
38-
const copyrightStr = 'Copyright (c)'
39-
const hasCopyrightHeader = content.indexOf(copyrightStr) >= 0
36+
const filesContainingHeader = files.filter((file) => {
37+
const hasCopyrightHeader = fs.readFileSync(file).includes('Copyright (c)')
4038
const ext = file.match(/\.[0-9a-z]+$/i)[0]
4139

42-
if (!hasCopyrightHeader) {
40+
if (hasCopyrightHeader) {
41+
return true
42+
} else {
4343
if (this.lintMode) {
4444
console.log(`${yellow}${file} ${red}missing copyright header`)
4545
return false
@@ -49,12 +49,10 @@ const copyright = {
4949
console.log(`${green}Copyright header succesfully written into ${magenta}${file}`)
5050
return true
5151
}
52-
} else {
53-
return true
5452
}
5553
})
5654

57-
if (filesMissingHeader.length !== files.length) {
55+
if (filesContainingHeader.length !== files.length) {
5856
console.log(`${red}${blackBG}ERROR${defaultBG} - Please run the copyright headers tool in this project`)
5957
process.exit(1)
6058
} else {
@@ -75,7 +73,7 @@ const copyright = {
7573
const supportedHeaders = path.join(__dirname, './headers')
7674
fs.readdir(supportedHeaders, (err, filenames) => {
7775
filenames.forEach((file) => {
78-
const extension = file.match(/\.[0-9a-z]+/i)[0]
76+
const extension = file.match(/\.[0-9a-z]+$/i)[0]
7977
this.langs[extension] = file
8078
})
8179
});

0 commit comments

Comments
Β (0)