Reworked the file dict keys to drop the suffix.
Lint / pre-commit Linting (push) Failing after 50s Details

This commit is contained in:
Philipp Horstenkamp 2023-11-26 18:16:52 +01:00
parent dbb1011e0c
commit 7141ce09e4
Signed by: Philipp
GPG Key ID: DD53EAC36AFB61B4
1 changed files with 7 additions and 2 deletions

View File

@ -26,8 +26,13 @@ function readFilesIntoDict(pattern, prefix) {
files.forEach(file => {
let readPromise = fs.promises.readFile(file, 'utf8')
.then(content => {
// Correctly remove the prefix from the filename
const key = prefix && file.startsWith(prefix) ? file.slice(prefix.length) : file;
// Remove the prefix from the filename and drop the file suffix
let key = file;
if (prefix && file.startsWith(prefix)) {
key = key.slice(prefix.length);
}
key = path.basename(key, path.extname(key)); // Drop the file suffix
fileDict[key] = content;
});