ensure non-ascii is converted properly

master
Gordon Williams 2021-11-01 11:38:58 +00:00
parent c0c8f36573
commit ed9daa139a
1 changed files with 7 additions and 1 deletions

View File

@ -102,7 +102,13 @@ function fileGetter(url) {
fs.writeFileSync(url, code);
}
}
return Promise.resolve(fs.readFileSync(url).toString("binary"));
var blob = fs.readFileSync(url);
var data;
if (url.endsWith(".js") || url.endsWith(".json"))
data = blob.toString(); // allow JS/etc to be written in UTF-8
else
data = blob.toString("binary")
return Promise.resolve(data);
}
// If file should be evaluated, try and do it...