Merge pull request #261 from dillonkearns/remove-obsolete-file-from-dist

Remove obsolete script from dist folder (it is now inlined as a <script>)
This commit is contained in:
Dillon Kearns 2021-12-14 14:09:18 -08:00 committed by GitHub
commit 9455a6fc3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 10 deletions

View File

@ -326,12 +326,6 @@ async function runTerser(filePath) {
}
async function copyAssets() {
await fsPromises.writeFile(
"dist/elm-pages.js",
await fsPromises.readFile(
path.join(__dirname, "../static-code/elm-pages.js")
)
);
fs.copyDirFlat("public", "dist");
}

View File

@ -124,7 +124,7 @@ async function runElmReview(cwd) {
child.on("close", function (code) {
console.log(`Ran elm-review in ${timeFrom(startTime)}`);
if (code === 0) {
reject();
resolve(scriptOutput);
} else {
resolve(scriptOutput);
}

View File

@ -320,7 +320,11 @@ async function start(options) {
if (req.url.includes("content.json")) {
res.writeHead(500, { "Content-Type": "application/json" });
if (emptyReviewError(reviewOutput)) {
res.end(error);
} else {
res.end(reviewOutput);
}
} else {
res.writeHead(500, { "Content-Type": "text/html" });
res.end(errorHtml());
@ -385,6 +389,18 @@ async function start(options) {
);
}
/**
* @param {string} reviewReportJsonString
*/
function emptyReviewError(reviewReportJsonString) {
try {
return JSON.parse(reviewReportJsonString).errors.length === 0;
} catch (e) {
console.trace("problem with format in reviewReportJsonString", e);
return true;
}
}
async function awaitElmMiddleware(req, res, next) {
if (req.url && req.url.startsWith("/elm.js")) {
try {
@ -506,12 +522,10 @@ function errorHtml() {
}
}
</style>
<!--<link rel="preload" href="/elm-pages.js" as="script"> -->
<link rel="preload" href="/index.js" as="script">
<!--<link rel="preload" href="/elm.js" as="script">-->
<script src="/hmr.js" type="text/javascript"></script>
<!--<script defer="defer" src="/elm.js" type="text/javascript"></script>-->
<!--<script defer="defer" src="/elm-pages.js" type="module"></script>-->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<script>