-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: simplify ProcessPromise._snapshot inners
#1281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
antongolub
commented
Jul 21, 2025
- Tests pass
- Appropriate changes to README are included in PR
There was a problem hiding this 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 refactors the ProcessPromise internal structure by consolidating context management into a unified _snapshot object approach. It simplifies the class by removing multiple individual private properties and centralizing configuration state.
- Replaces individual properties (
_cmd,_from,_stdio, etc.) with a consolidated_snapshotobject approach - Introduces a
Snapshottype andgetSnapshothelper function for better type safety - Removes redundant property accessors and simplifies the promise resolution logic
Reviewed Changes
Copilot reviewed 8 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/core.ts | Major refactoring of ProcessPromise class to use consolidated snapshot approach, introduces Snapshot type and getSnapshot helper |
| test/core.test.js | Updates test setup to use new snapshot structure and adds test for kill() with empty pid |
| src/cli.ts | Minor code reorganization - moves export statement and simplifies conditional logic |
| package.json | Version bump to 8.7.2 and esbuild dependency update |
| build/ files | Generated build artifacts reflecting the core changes |
| .size-limit.json | Updated size limits reflecting bundle size changes |
| } | ||
| const from = getCallerLocation() | ||
| if (pieces.some((p) => p == undefined)) | ||
| if (pieces.some((p) => p == null)) |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change from p == undefined to p == null alters the behavior. The original check with == undefined would catch both undefined and null values, while == null only catches null and undefined. Consider using strict equality === null || === undefined or reverting to the original logic if the intention was to catch both falsy values.
| if (pieces.some((p) => p == null)) | |
| if (pieces.some((p) => p === null || p === undefined)) |