Reworked the file dict keys to drop the suffix.
Some checks failed
Lint / pre-commit Linting (push) Failing after 50s
Some checks failed
Lint / pre-commit Linting (push) Failing after 50s
This commit is contained in:
parent
dbb1011e0c
commit
7141ce09e4
9
index.js
9
index.js
@ -26,8 +26,13 @@ function readFilesIntoDict(pattern, prefix) {
|
|||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
let readPromise = fs.promises.readFile(file, 'utf8')
|
let readPromise = fs.promises.readFile(file, 'utf8')
|
||||||
.then(content => {
|
.then(content => {
|
||||||
// Correctly remove the prefix from the filename
|
// Remove the prefix from the filename and drop the file suffix
|
||||||
const key = prefix && file.startsWith(prefix) ? file.slice(prefix.length) : file;
|
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;
|
fileDict[key] = content;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user