lukeed/watchlist

Command not invoked when subdirectory renamed on macOS

CMessinides opened this issue · 3 comments

Description

When watchlist is watching a directory, and I rename a subdirectory within that directory, watchlist does not invoke my command.

Specs

macOS 10.14.6
Node 14.4.0
watchlist 0.2.3

Severity

Low (a minor inconvenience at most). See workaround below.

Current Workaround

Rename the subdirectory and then touch a file nested underneath that subdirectory.

Background

I'm working on an HTML parser and using uvu as a testing framework. I have a directory test with all my test files, and within that, a subdirectory called tokenizer/cases, which contains fixture files for my tokenizer tests, like so:

test
├── tokenizer
│   └── cases // Fixtures. Each subdirectory under this dir contains input and output fixtures for a single test case.
│       ├── attrs
│       │   ├── input.html
│       │   └── output.json
│       ├── comments
│       │   ├── input.html
│       │   └── output.json
│       │ ...
│       ├── unexpected-equals-sign-before-attr-name
│       │   ├── input.html
│       │   └── output.json
│       └── unexpected-slash-in-tag
│           ├── input.html
│           └── output.json
└── tokenizer.test.ts // The tokenizer test file

I have a bit of code in tokenizer.test.ts that scrapes this list of fixtures and defines a test for each test case. Here's where directory renaming comes in: I've set it up so that if I change the name of a fixture directory like tokenizer/cases/attrs to tokenizer/cases/only.attrs, it will run only that test case (using test.only()), and likewise, if I name it tokenizer/cases/skip.attrs, it will skip that test case. So I'm often renaming these subdirectories as I'm working to toggle tests on and off, but if watchlist test -- yarn test is running, it won't invoke yarn test until I trigger some other kind of filesystem event (like my current workaround).

Like I said above, this is very low severity issue, and also a bit of a self-inflicted one. 🙂 I'm mostly curious if this is something you'd want to support in watchlist.

Thanks for your time and your work on uvu and watchlist. This is my first project with both, and they've been a joy to use.

This issue does not exist in uvu-watch

Hi @CMessinides,

Thanks for the kind words :) And sorry for the delay

I was not able to reproduce this at the time of your report, or again now that I'm circling back. I tried with multiple Node versions (14.4.0, 14.15.3, 16.2.0, 16.7.0) and with this structure:

test
├── howdy
│   └── hello.ts
└── index.js

Here's the example using your Node version:

Screen Shot 2021-08-27 at 5 27 09 PM

Are you still encountering this issue?

Sorry – brain fart 🤦 I was reproducing it just fine... just had my logs in the wrong place.