Skip to content

chore: add execProcess wrapper and refactor poetryUtils (Fixes #1239)#1240

Open
karthiknadig wants to merge 4 commits intomainfrom
chore/issue-1239
Open

chore: add execProcess wrapper and refactor poetryUtils (Fixes #1239)#1240
karthiknadig wants to merge 4 commits intomainfrom
chore/issue-1239

Conversation

@karthiknadig
Copy link
Member

@karthiknadig karthiknadig commented Feb 16, 2026

This PR adds an execProcess wrapper to childProcess.apis.ts and refactors poetryUtils.ts to use it, improving testability.

Changes:

  • Added execProcess function to src/common/childProcess.apis.ts as a wrapper around cp.exec with PYTHONUTF8 handling
  • Refactored src/managers/poetry/poetryUtils.ts to use execProcess instead of direct child_process import
  • Fixed a pre-existing regex bug in getPoetryVersion that didn't handle the space in Poetry 1.x version output format
  • Added unit tests in poetryUtils.unit.test.ts demonstrating the mocking pattern for execProcess

Testing:

  • All unit tests pass (660 passing)
  • Lint passes with no errors

Note: This is a partial implementation of #1239. The acceptance criteria for auditing fs imports is deferred to a future PR to keep this change focused.

For #1239

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves testability and consistency of child-process usage by introducing an execProcess() wrapper in src/common/childProcess.apis.ts and refactoring Poetry utilities to use it, while also fixing Poetry 1.x version parsing.

Changes:

  • Added execProcess() wrapper around cp.exec() in src/common/childProcess.apis.ts.
  • Refactored src/managers/poetry/poetryUtils.ts to use execProcess() instead of a direct child_process import + promisify.
  • Added unit tests covering getPoetryVersion() parsing and demonstrating stubbing execProcess().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/common/childProcess.apis.ts Adds execProcess() wrapper to centralize cp.exec usage and improve mockability.
src/managers/poetry/poetryUtils.ts Switches Poetry exec calls to the wrapper and adjusts version-regex parsing for Poetry 1.x output.
src/test/managers/poetry/poetryUtils.unit.test.ts Adds unit tests that stub childProcess.apis.execProcess() and validate version parsing.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/common/childProcess.apis.ts:23

  • The comment states "with PYTHONUTF8 as default", but the spread order { PYTHONUTF8: '1', ...process.env, ...options?.env } means PYTHONUTF8='1' has the LOWEST priority and will be overridden by both process.env and options.env if they contain PYTHONUTF8. While this is the correct JavaScript behavior for setting defaults, the comment could be clearer.

Consider rephrasing to: "Sets PYTHONUTF8='1' as a fallback default (can be overridden by process.env or options.env)"

    // Always inherit process.env, then merge options.env overrides, with PYTHONUTF8 as default

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants