Skip to content

Commit 1a48a4f

Browse files
committed
wait for index.html to exists before starting terriajs-servre
1 parent ea6a329 commit 1a48a4f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

gulpfile.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,5 +261,24 @@ gulp.task("terriajs-server", terriajsServerGulpTask(3001));
261261
gulp.task("build", gulp.series("copy-terriajs-assets", "build-app"));
262262
gulp.task("release", gulp.series("copy-terriajs-assets", "release-app"));
263263
gulp.task("watch", gulp.parallel("watch-terriajs-assets", "watch-app"));
264-
gulp.task("dev", gulp.parallel("watch", "terriajs-server"));
264+
// Simple task that waits for index.html then starts server
265+
gulp.task(
266+
"dev",
267+
gulp.parallel("watch", function startServerWhenReady(done) {
268+
const indexFile = path.join(__dirname, "wwwroot", "index.html");
269+
270+
if (fs.existsSync(indexFile)) {
271+
terriajsServerGulpTask(3001)(done);
272+
return;
273+
}
274+
var watcher = gulp.watch(
275+
path.join(__dirname, "wwwroot", "index.html"),
276+
watchOptions
277+
);
278+
watcher.on("add", function () {
279+
watcher.close();
280+
terriajsServerGulpTask(3001)(done);
281+
});
282+
})
283+
);
265284
gulp.task("default", gulp.series("lint", "build"));

0 commit comments

Comments
 (0)