Skip to content

Commit 2c86eaf

Browse files
committed
error when templates directory is missing
1 parent 619c803 commit 2c86eaf

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

vite-plugin-openfl.mjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,25 @@ export default function openflPlugin() {
8686
const isServeCommand = !config || config.command === "serve";
8787
const projectDir = path.dirname(id);
8888
const mode = isServeCommand ? "-debug" : "-release";
89-
const templateDir = path.join(
90-
"templates",
91-
usesGenes ? "genes" : "default"
89+
const templateDir = path.resolve(
90+
import.meta.dirname,
91+
path.join("templates", usesGenes ? "genes" : "default")
9292
);
93+
if (
94+
!fs.existsSync(templateDir) ||
95+
!fs.statSync(templateDir).isDirectory()
96+
) {
97+
this.error("Cannot find Lime templates: " + templateDir);
98+
return;
99+
}
93100
const result = child_process.spawnSync("haxelib", [
94101
"run",
95102
"lime",
96103
"build",
97104
id,
98105
"html5",
99106
mode,
100-
`--template=${path.resolve(import.meta.dirname, templateDir)}`,
107+
`--template=${templateDir}`,
101108
]);
102109
const logger = createLogger("info");
103110
result.output.forEach((line) => {

0 commit comments

Comments
 (0)