forked from activepieces/activepieces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
turbowatch.ts
36 lines (33 loc) · 1.25 KB
/
turbowatch.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { defineConfig, type ChangeEvent } from 'turbowatch'
export default defineConfig({
project: `${__dirname}/packages/pieces`,
triggers: [
{
expression: ['match', '*.ts', 'basename'],
name: 'build-pieces',
initialRun: true,
interruptible: false,
persistent: false,
onChange: async ({ spawn, first, files } :ChangeEvent) => {
if (first) {
const pieces = process.env.AP_DEV_PIECES?.split(',').map(p => `pieces-${p}`).join(',')
await spawn`nx run-many -t build --projects=${pieces}`
return
}
const projects = files
.map(file => {
const fileNameRegex = /^.+pieces\/(?<pieceName>.+)\/src.+$/
const matchResult = file.name.match(fileNameRegex)
const pieceName = matchResult?.groups?.pieceName
return `pieces-${pieceName}`
})
.filter(Boolean)
.join(',')
await spawn`nx run-many -t build --projects=${projects}`
},
},
],
debounce: {
wait: 1000,
},
})