Skip to content

Changes to --dir, --cwd, --script-mode, add configSearchPath #1197

Description

@cspotcode

@blakeembrey Do you have time to offer a sanity-check on these breaking changes? You might have some helpful historical perspective that I don't. I suspect that ts-node's current behavior is an understandable result of organic evolution over time, but we can make some changes to keep it clean and intuitive.

While working on #1155 I realized that --dir and --script-mode have some interesting behaviors. --dir is documented to change the location of config file resolution, but it actually does much more: it overrides process.cwd(). As far as I know, this affects TS_NODE_SCOPE and --project in a confusing way. For example, ts-node-script ./src/bin/main.ts will set cwd to ./src/bin, affecting the interpretation of --scope and --project, and affecting relative paths logged in error messages. A user would be confused by that.

With that in mind, do the following changes sound reasonable?

Proposed Changes

  • rename --dir to --cwd so behavior is more intuitive. Keep --dir as deprecated for backwards compat.
  • Rewrite --cwd docs to state that it overrides the cwd, which affects lots of things (can copy phrasing from git -C docs)
  • [BREAKING] update --script-mode so that it affects tsconfig discovery but not cwd. Can accomplish via a new configSearchPath API option.

Questions

  • Is configSearchPath a good name? configSearchDir?
  • Should configSearchPath be exposed as a CLI flag / env var? I say no

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions