Skip to content

Commit

Permalink
chore: update example to have phase hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Dec 5, 2023
1 parent 1148f81 commit afd3922
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
27 changes: 7 additions & 20 deletions examples/01_express/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ buildContext.add('client', {

let spawnedTask

buildContext.hook('client:complete', () => {
console.log('Client: Built')
})

buildContext.hook('server:complete', () => {
console.log('Server: Built')
if (!isDev) return

if (spawnedTask) {
Expand All @@ -54,24 +59,6 @@ buildContext.hook('complete', async () => {
process.exit(0)
})

function createChain() {
let agg = Promise.resolve()
const _chainer = fn => {
agg = agg.then(fn)
}
_chainer.value = async () => {
await agg
return null
}
return _chainer
}

const chain = createChain()

if (isDev) {
chain(() => buildContext.watch())
}

chain(() => buildContext.build())
if (isDev) await buildContext.watch()

await chain.value
await buildContext.build()
6 changes: 3 additions & 3 deletions examples/01_express/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit afd3922

Please sign in to comment.