mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-29 14:56:36 +03:00
Show error message when all Page Templates are removed.
This commit is contained in:
parent
594888776b
commit
1ea3a81316
@ -13,6 +13,8 @@ async function generate() {
|
||||
}
|
||||
|
||||
async function writeFiles() {
|
||||
const cliCode = generateTemplateModuleConnector("cli");
|
||||
const browserCode = generateTemplateModuleConnector("browser");
|
||||
ensureDirSync("./elm-stuff");
|
||||
ensureDirSync("./gen");
|
||||
ensureDirSync("./elm-stuff/elm-pages");
|
||||
@ -31,13 +33,11 @@ async function writeFiles() {
|
||||
|
||||
// write `Pages.elm` with cli interface
|
||||
fs.writeFileSync("./elm-stuff/elm-pages/Pages.elm", elmPagesCliFile());
|
||||
const cliCode = generateTemplateModuleConnector("cli");
|
||||
fs.writeFileSync(
|
||||
"./elm-stuff/elm-pages/TemplateModulesBeta.elm",
|
||||
cliCode.mainModule
|
||||
);
|
||||
fs.writeFileSync("./elm-stuff/elm-pages/Route.elm", cliCode.routesModule);
|
||||
const browserCode = generateTemplateModuleConnector("browser");
|
||||
fs.writeFileSync("./gen/TemplateModulesBeta.elm", browserCode.mainModule);
|
||||
fs.writeFileSync("./gen/Route.elm", browserCode.routesModule);
|
||||
|
||||
|
@ -113,12 +113,26 @@ async function start(options) {
|
||||
} else if (pathThatChanged.endsWith(".elm")) {
|
||||
if (elmMakeRunning) {
|
||||
} else {
|
||||
let codegenError = null;
|
||||
if (needToRerunCodegen(eventName, pathThatChanged)) {
|
||||
await codegen.generate();
|
||||
try {
|
||||
await codegen.generate();
|
||||
} catch (error) {
|
||||
codegenError = error;
|
||||
}
|
||||
}
|
||||
elmMakeRunning = true;
|
||||
clientElmMakeProcess = compileElmForBrowser();
|
||||
pendingCliCompile = compileCliApp();
|
||||
if (codegenError) {
|
||||
const errorJson = JSON.stringify({
|
||||
type: "compile-errors",
|
||||
errors: [codegenError],
|
||||
});
|
||||
clientElmMakeProcess = Promise.reject(errorJson);
|
||||
pendingCliCompile = Promise.reject(errorJson);
|
||||
} else {
|
||||
clientElmMakeProcess = compileElmForBrowser();
|
||||
pendingCliCompile = compileCliApp();
|
||||
}
|
||||
let timestamp = Date.now();
|
||||
|
||||
Promise.all([clientElmMakeProcess, pendingCliCompile])
|
||||
|
@ -16,7 +16,24 @@ function generateTemplateModuleConnector(phase) {
|
||||
}
|
||||
});
|
||||
if (templates.length <= 0) {
|
||||
throw `I couldn't find any Page Templates. Try using elm-pages add Index to get started with your first page!`;
|
||||
throw {
|
||||
path: "",
|
||||
name: "TemplateModulesBeta",
|
||||
problems: [
|
||||
{
|
||||
title: "Could not generate entrypoint",
|
||||
message: [
|
||||
`I couldn't find any Page Templates. Try creating your first page by running: \n\n`,
|
||||
{
|
||||
bold: false,
|
||||
underline: false,
|
||||
color: "yellow",
|
||||
string: "elm-pages add Index",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user