-
Notifications
You must be signed in to change notification settings - Fork 7
/
turbowatch.ts
47 lines (43 loc) · 1.41 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
37
38
39
40
41
42
43
44
45
46
47
import { watch } from 'turbowatch';
import path from 'node:path';
function npmName(pkgName: string) {
if (pkgName === 'api-messages') {
return `@janeirodigital/sai-api-messages`;
}
return `@janeirodigital/interop-${pkgName}`;
}
// TODO watch service componentjs configs
const packages = ['utils', 'data-model', 'application', 'authorization-agent', 'api-messages'];
for (const pkgName of packages) {
void watch({
project: path.join(__dirname, `packages/${pkgName}`),
triggers: [
{
expression: ['allof', ['not', ['dirname', 'node_modules']], ['match', '*.ts', 'basename']],
name: 'build',
onChange: async ({ spawn }) => {
await spawn`pnpm turbo run build --filter=${npmName(pkgName)}`;
}
}
]
});
}
void watch({
project: path.join(__dirname, 'packages/service'),
triggers: [
{
expression: [
'anyof',
['allof', ['dirname', 'node_modules'], ['dirname', 'dist'], ['match', '*', 'basename']],
['allof', ['not', ['dirname', 'node_modules']], ['dirname', 'src'], ['match', '*', 'basename']]
],
// Because of this setting, Turbowatch will kill the processes that spawn starts
// when it detects changes when it detects a change.
interruptible: true,
name: 'start-server',
onChange: async ({ spawn }) => {
await spawn`pnpm --filter=@janeirodigital/sai-server debug`;
}
}
]
});