fix: dont add styles twice initially

happens with the serveAllStyles option

The styles will be already be added later by the watcher.
This seems to be intoruced with the switch to chokidar
in ea89d11021

Instead we could also add the option ignoreInitial to chokidar

Signed-off-by: David Weber | geOps <david.weber@geops.com>
This commit is contained in:
David Weber | geOps 2024-01-01 19:46:16 +01:00 committed by Andrew Calcutt
parent 26d8066cdc
commit fe435ae5c4

View file

@ -295,21 +295,6 @@ function start(opts) {
}
if (options.serveAllStyles) {
fs.readdir(options.paths.styles, { withFileTypes: true }, (err, files) => {
if (err) {
return;
}
for (const file of files) {
if (file.isFile() && path.extname(file.name).toLowerCase() == '.json') {
const id = path.basename(file.name, '.json');
const item = {
style: file.name,
};
addStyle(id, item, false, false);
}
}
});
const watcher = chokidar.watch(
path.join(options.paths.styles, '*.json'),
{},