Skip to content

Support absolute targetPackagePath independent of cwd - #204

Merged
0x80 merged 2 commits into
mainfrom
thijs/0828-absolute-target-package-path
Aug 28, 2026
Merged

Support absolute targetPackagePath independent of cwd#204
0x80 merged 2 commits into
mainfrom
thijs/0828-absolute-target-package-path

Conversation

@0x80

@0x80 0x80 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

targetPackagePath was resolved with path.join(process.cwd(), targetPackagePath) and the workspace root pinned to process.cwd(), so callers had to guarantee the process runs at the workspace root. An absolute path produced a broken join.

An absolute targetPackagePath now targets that directory directly, and the workspace root is resolved the same way as the no-targetPackagePath case: from the workspaceRoot setting, or auto-detected by walking upward from the target package directory. Relative paths keep their exact existing semantics, so this is purely additive — absolute paths were previously a broken input nobody could depend on.

Motivation: the firebase-tools PR upstreaming the isolate integration (firebase/firebase-tools#10996) got review feedback that its isolate call breaks when the CLI runs from a subdirectory of the project. With this change firebase-tools can pass its already-resolved absolute source directory and be correct from any cwd, without a process.chdir workaround.

Decisions:

  • Gated the new behavior on path.isAbsolute rather than changing relative-path semantics, to stay non-breaking for existing configs.
  • With an absolute path, workspaceRoot is honored instead of ignored (it was only ignored before because cwd was assumed to be the root).

0x80 added 2 commits August 28, 2026 19:23
A relative targetPackagePath keeps its existing semantics: resolved
against the current working directory, which is assumed to be the
workspace root. An absolute path previously produced a broken join
against cwd; it now targets that directory directly and resolves the
workspace root like the no-targetPackagePath case does, from the
workspaceRoot setting or by walking upward from the target package.
This lets callers such as firebase-tools invoke isolate() correctly
regardless of the directory the process runs from.
Copilot AI lite review requested due to automatic review settings August 28, 2026 17:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped, preserves existing relative-path behavior, and includes direct unit test coverage for the new absolute-path semantics and key edge cases.

Pull request overview

This PR updates resolveWorkspacePaths so an absolute targetPackagePath works correctly regardless of the current working directory, resolving the workspace root via workspaceRoot (when set) or via auto-detection from the target package directory—matching the behavior of the no-targetPackagePath case.

Changes:

  • Support absolute targetPackagePath without incorrectly pinning workspaceRootDir to process.cwd().
  • Add unit tests covering relative vs absolute targetPackagePath behavior, including workspaceRoot honoring and failure mode when auto-detection can’t find a root.
  • Update configuration documentation to describe the relative/absolute semantics clearly.
File summaries
File Description
src/lib/config.ts Adjusts workspace path resolution logic to treat absolute targetPackagePath as cwd-independent and to honor/auto-detect workspaceRootDir accordingly.
src/lib/config.test.ts Adds targeted tests for resolveWorkspacePaths covering new absolute-path behavior and existing relative-path behavior.
docs/configuration.md Documents the new absolute targetPackagePath behavior and clarifies when workspaceRoot is ignored vs honored.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@0x80
0x80 merged commit ef94d1c into main Aug 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants