gajus / turbowatch

Extremely fast file change detector and task orchestrator for Node.js.
Other
943 stars 23 forks source link

How to match files on Windows? #20

Closed marek-hanzal closed 1 year ago

marek-hanzal commented 1 year ago

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!

marek-hanzal commented 1 year ago

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.

marek-hanzal commented 1 year ago

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 1 year ago

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.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 2.4.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: