Skip to content

Codegen in --watch mode doesn't handle deletions/renames fully #873

@brabeji

Description

@brabeji

Intended outcome:

--watch is able to track added, deleted and renamed files.

Actual outcome:

Currently only changes in preexisting files trigger watch.

How to reproduce the issue:
Try to create a query file matching includes pattern.

Further info:
There are two parts to this problem:

  1. Watching logic is insufficient (no deletion and rename handling at least):

    watcher.on("all", (event, file) => {

  2. Even after quick fix I made locally to handle specific cases:

...
            watcher.on("changed", (file) => {
                console.log('Watch event: changed', file);
                this.project.fileDidChange(vscode_uri_1.default.file(file).toString());
            });
            watcher.on("deleted", (file) => {
                console.log('Watch event: deleted', file);
                this.project.fileWasDeleted(vscode_uri_1.default.file(file).toString());
            });
            watcher.on("added", (file) => {
                console.log('Watch event: added', file);
                this.project.fileDidChange(vscode_uri_1.default.file(file).toString());
            });
            watcher.on("renamed", (file, newFile) => {
                console.log('Watch event: renamed', file);
                this.project.fileWasDeleted(vscode_uri_1.default.file(file).toString());
                this.project.fileDidChange(vscode_uri_1.default.file(newFile).toString());
            });
...

the result is not satisfactory. For example deletion of enclosing folder doesn't trigger file deletion. Gaze lib used for watching seems quite unreliable in edge-cases.
Also it doesn't handle globs with relative paths (--includes './src/**/*.gql').

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions