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

Commit 81ce1a1

Browse files
author
Cdok
committed
Stores the contents of the header files in obj
This commit stores the contents of the copyright headers in the copyright.langs object, so that the contents are only read once instead of for each file
1 parent 12b9b05 commit 81ce1a1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

copyright/copyright.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ const copyright = {
5858
console.log(`${red}${blackBG}ERROR${defaultBG} - ${ext} is not supported (yet)`)
5959
process.exit(1)
6060
} else {
61-
const textPath = path.join(__dirname, `./headers/${this.langs[ext]}`)
62-
return fs.readFileSync(textPath).toString().replace('year', new Date().getFullYear())
61+
return this.langs[ext]
6362
}
6463
},
6564
buildSupportedExtensions() {
@@ -68,7 +67,9 @@ const copyright = {
6867
.readdirSync(headerDir)
6968
.forEach((file) => {
7069
const extension = file.match(/\.[0-9a-z]+$/i)[0]
71-
this.langs[extension] = file
70+
const textPath = path.join(headerDir, file)
71+
const content = fs.readFileSync(textPath).toString().replace('year', new Date().getFullYear())
72+
this.langs[extension] = content
7273
})
7374
}
7475
}

0 commit comments

Comments
 (0)