Skip to content

Running mcb in a directory path containing glob characters (e.g. [ ]) makes it unable to watch for file changes #32

Description

@b0xfox

MCB version 4.1.1

Steps to reproduce

Setup

mcb create "mcb-test/Project - version"
mcb create "mcb-test/Project - [ version ]"

Case 1 (no brackets in path)

cd "mcb-test/Project - version"
mcb watch

Modify a source file.

Expected: file changes are detected and rebuild triggers
Result: works correctly

Case 2 (square brackets in path)

cd "mcb-test/Project - [ version ]"
mcb watch

Modify a source file.

Expected: file changes are detected and rebuild triggers
Result: initial build runs, but no subsequent file changes are detected

From briefly looking through the mcb source code, it appears chokidar is interpreting the provided path using glob semantics.

https://github.com/mc-build/mcb/blob/ts-rev/src/mcb/AppMain.ts#L426

const watcher = chokidar.watch(path.join(opts.baseDir, "src"), {
  ignoreInitial: true,
  awaitWriteFinish: true,
});

I looked for any relevant issues and found a few related discussions here:
paulmillr/chokidar#1007
paulmillr/chokidar#300
paulmillr/chokidar#598

chokidar provides a disableGlobbing option which could be relevant

This isn't a critical issue; I can simply not use glob characters in my directory names. But, a possible fix could be using disableGlobbing: true or escaping the watch path before passing it to chokidar. Only noting in case others are confused why mcb silently fails to rebuild changes.

Update: I tested this locally and adding disableGlobbing:true to the chokidar.watch(...) options appears to resolve the issue. Happy to open a PR if that would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions