Add "serveAllStyles" option + watch the directory

This commit is contained in:
Petr Sloup
2020-01-07 15:59:38 +01:00
parent cb700181d3
commit d7a34f3a74
5 changed files with 110 additions and 29 deletions

View File

@@ -663,7 +663,12 @@ module.exports = {
const styleFile = params.style;
const styleJSONPath = path.resolve(options.paths.styles, styleFile);
styleJSON = clone(require(styleJSONPath));
try {
styleJSON = JSON.parse(fs.readFileSync(styleJSONPath));
} catch (e) {
console.log('Error parsing style file');
return false;
}
if (styleJSON.sprite && !httpTester.test(styleJSON.sprite)) {
styleJSON.sprite = 'sprites://' +
@@ -798,5 +803,14 @@ module.exports = {
});
return Promise.all([renderersReadyPromise]);
}
},
remove: (repo, id) => {
let item = repo[id];
if (item) {
item.map.renderers.forEach(pool => {
pool.close();
});
}
delete repo[id];
},
};