diff --git a/gulpfile.ts b/gulpfile.ts index 21e60a9..8e6f63c 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -3,7 +3,7 @@ import GulpClient, { TaskFunction } from "gulp"; import path from "upath"; import { Context } from "./gulp/Context.js"; -const { dest, parallel, series, src, watch } = GulpClient; +const { dest, parallel, series, src, task, watch } = GulpClient; const { join } = path; const context = new Context(); @@ -119,38 +119,52 @@ function BrowserSync(syncer: BrowserSyncInstance, filePath?: string): TaskFuncti /** * Builds and watches the files for changes. */ -export function Watch(): void +export let Watch: TaskFunction = async (): Promise => { - let syncer = browserSync.create(); - Build(); + return new Promise( + (resolve, reject) => + { + series(Build)( + (error) => + { + if (error) + { + reject(error); + } + else + { + let syncer = browserSync.create(); - syncer.init({ - open: false, - server: context.StaticPath(), - online: false - }); - - watch( - context.SourcePath(context.JSDirName), - series( - JavaScript, - BrowserSync(syncer, "*.js"))); - - watch( - context.SourcePath(context.StyleDirName, "**", "*.css"), - series( - Styles, - BrowserSync(syncer, "*.css"))); - - watch( - context.SourcePath(context.AssetDirName), - series( - Assets, - BrowserSync(syncer, join(context.AssetDirName, "**", "*")))); - - watch( - context.SourcePath("**", "*.html"), - series( - WebPages, - BrowserSync(syncer, "*.html"))); + syncer.init({ + open: false, + server: context.StaticPath(), + online: false + }); + + watch( + context.SourcePath(context.JSDirName), + series( + JavaScript, + BrowserSync(syncer, "*.js"))); + + watch( + context.SourcePath(context.StyleDirName, "**", "*.css"), + series( + Styles, + BrowserSync(syncer, "*.css"))); + + watch( + context.SourcePath(context.AssetDirName), + series( + Assets, + BrowserSync(syncer, join(context.AssetDirName, "**", "*")))); + + watch( + context.SourcePath("**", "*.html"), + series( + WebPages, + BrowserSync(syncer, "*.html"))); + } + }); + }); }