fix dev server crash on file not found

This commit is contained in:
Remko Tronçon 2022-04-17 15:46:42 +02:00
parent 74bb57b72e
commit ef01a303ca

View file

@ -117,8 +117,12 @@ if (watch) {
// Simple static file server
createServer(async function (req, res) {
let f = path.join(__dirname, "public", req.url);
if ((await fs.promises.lstat(f)).isDirectory()) {
f = path.join(f, "index.html");
try {
if ((await fs.promises.lstat(f)).isDirectory()) {
f = path.join(f, "index.html");
}
} catch (e) {
// pass
}
try {
const data = await fs.promises.readFile(f);