Skip to content

Commit

Permalink
Include a link to the scene that needs fixing in build log when scene…
Browse files Browse the repository at this point in the history
… errors are detected during build
  • Loading branch information
chrismaltby committed Sep 15, 2024
1 parent fcf2259 commit 7719f11
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/lib/compiler/compileData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ export const precompileScenes = (

if (!backgroundWithCommonTileset) {
warnings(
`Scene #${sceneIndex + 1} ${
`Error in scene '${scene.symbol}' : ${
scene.name ? `'${scene.name}'` : ""
} includes a common tileset that can't be located.`
);
Expand All @@ -989,7 +989,7 @@ export const precompileScenes = (

if (!background) {
throw new Error(
`Scene #${sceneIndex + 1} ${
`Error in scene '${scene.symbol}' : ${
scene.name ? `'${scene.name}'` : ""
} has missing or no background assigned.`
);
Expand All @@ -999,7 +999,7 @@ export const precompileScenes = (

if (scene.actors.length > MAX_ACTORS) {
warnings(
`Scene #${sceneIndex + 1} ${
`Error in scene '${scene.symbol}' : ${
scene.name ? `'${scene.name}'` : ""
} contains ${
scene.actors.length
Expand All @@ -1009,7 +1009,7 @@ export const precompileScenes = (

if (scene.triggers.length > MAX_TRIGGERS) {
warnings(
`Scene #${sceneIndex + 1} ${
`Error in scene '${scene.symbol}' : ${
scene.name ? `'${scene.name}'` : ""
} contains ${
scene.triggers.length
Expand Down
19 changes: 18 additions & 1 deletion src/store/features/console/consoleMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const getLinkToSymbol = (
}

const scene = allScenes.find((s) => {
return symbol.startsWith(`${s.symbol}_`);
return symbol.startsWith(s.symbol);
});

if (scene) {
Expand Down Expand Up @@ -135,6 +135,23 @@ const consoleMiddleware: Middleware<Dispatch, RootState> =
});
}
}
} else if (action.payload.text.startsWith("Error in scene")) {
const symbol = action.payload.text.match(
/Error in scene '([^']*)'/
)?.[1];
if (symbol) {
const state = store.getState();
const link = getLinkToSymbol(symbol, state);
if (link) {
return next({
...action,
payload: {
text: action.payload.text,
link,
},
});
}
}
} else if (action.payload.text.includes("removing")) {
const symbol = action.payload.text.match(
/removing .*[\\/]([^\\/]*).o/
Expand Down

0 comments on commit 7719f11

Please sign in to comment.