refactor: simplify ProcessPromise._snapshot inners#1281
Merged
Conversation
antongolub
commented
Jul 21, 2025
Collaborator
- Tests pass
- Appropriate changes to README are included in PR
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
Suggested change
| if (pieces.some((p) => p == null)) | |
| if (pieces.some((p) => p === null || p === undefined)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.