Skip to content

Add --watch-path-if-exists #58436

Closed as not planned
Closed as not planned
@xzyfer

Description

@xzyfer

What is the problem this feature will solve?

With --watch and --env-file it became possible to replace fs watcher packages with native functionality with something like

node --env-file=.env --watch-path=.env --watch main.js

#50993 introduced --env-file-if-exists which makes it possible to replace dotenv loader libraries with native functionality with something like

node --env-file=.env --env-file-if-exists=.env.local --watch-path=.env --watch main.js

However there is no complimentary --watch-path-if-exists so it's not possible for the watcher to restart on changes to --env-file-if-exists paths.

Instead an error is thrown

Error: ENOENT: no such file or directory, watch '/Users/xzyfer/dev/my-ap/.env.local'

What is the feature you are proposing to solve the problem?

Add a flag (or other mechanism) complimentary to #50993 to indicate that a path should be watched only it's found, and to throw otherwise.

What alternatives have you considered?

touching the watched files before running node; invoking node via a shell script and "building up" the cli opts; pre-existing dotenv loaders such as the dotenv package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    Status

    Awaiting Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions