warn when multiple projects use the same project path
gajus opened this issue · 1 comments
gajus commented
Imagine two services:
/apps/foo
/apps/bar
Both have the same bin/watch
script:
import path from 'node:path';
import { watch } from 'turbowatch';
void watch({
project: path.resolve('..'),
triggers: [
{
expression: ['match', '*.ts', 'basename'],
interruptible: false,
name: 'start-server',
onChange: async ({ spawn }) => {
return spawn`tsx src/bin/server.ts`;
},
},
],
});
at first, this may seem correct, and it will even work. However, notice that the project
resolves a relative path ..
to CWD, rather than the directory, i.e. for both scripts it will be /apps
. Whereas the intention was:
import path from 'node:path';
import { watch } from 'turbowatch';
void watch({
- project: path.resolve('..'),
+ project: path.resolve(__dirname, '..'),
triggers: [
{
expression: ['match', '*.ts', 'basename'],
interruptible: false,
name: 'start-server',
onChange: async ({ spawn }) => {
return spawn`tsx src/bin/server.ts`;
},
},
],
});
There are definitely valid use cases for overlapping project directories. However, in most cases this is not intentional and logging a warning would help the end user troubleshoot.
gajus commented
In retrospect, this feels like an overkill. We are now providing enough logs to make it clear what is being watched.