gajus/turbowatch

How to match files on Windows?

marek-hanzal opened this issue ยท 4 comments

Hello,

I'm trying to setup turbowatch (2.3.2) with

export default watch({
    project: __dirname,
    triggers: [
        {
            initialRun: false,
            expression: [
                "anyof",
                [
                    "match",
                    "src/**/*.**",
                    'wholename'
                ],
                [
                    "match",
                    "*.json",
                    "basename",
                ],
            ],
            name:       "build",
            onChange:   async ({spawn}) => {
                await spawn`npm run build:esbuild`;
                await spawn`npm run build:types`;
            },
        },
    ],
});

This was my original attempt or a way how I was expected it would work:

watch({
    project,
    triggers: [
        {
            initialRun: false,
            expression: [
                "anyof",
                [
                    "dirname",
                    "src",
                ],
                [
                    "match",
                    "*.json",
                    "basename",
                ],
            ],
            name:       "build",
            onChange:   async ({spawn}) => {
                await spawn`npm run build:esbuild`;
                await spawn`npm run build:types`;
            },
        },
    ],
})

But with the new version (when moved from watchman) I cannot (or don't know how) setup watching just subtree of the project. Json files are catched correctly, but watching in src does not work (means not triggered). Please, what am I doing wrong or how to setup the thing correctly?

The idea is I've god .ts files generated in the lib, so when a new .d.ts files appears, turbowatch triggeres again, so I just want to watch src and a few other files (package.json, tsconfig, ...).

Thank you!

Soo, one moment:
image

I'm on windows, thus I'm getting \, so adding / won't trigger the stuff... now I'll try to investigate micromatch and how it should work.

Ok, it was quite a fun find it, but I get it:
image

Maybe it would be nice to extend docs and put reference to the individual matchers (dirname with / as it would not work on Win) and usage of Micromatch, so people can overcome it without messing with your source code to find, how the thing works.

I don't want to sound rude, I'm happy I've found your lib, so at least I can say - good work.

gajus commented

I am not a windows user, so cannot easily debug and/or fix this, but PR is welcome. We can add windows to the test matrix as well.

๐ŸŽ‰ This issue has been resolved in version 2.4.0 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€