-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: accept custom delimiter for lines()
#1220
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
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
Adds support for a custom separator for the lines() API so users can split output on any string or regex rather than just newlines.
- Updates
getLinesto accept adelimiterparameter and uses it in both async iteration and.lines() - Exposes a new
delimiteroption in shell invocations and passes it through toProcessPromiseandProcessOutput - Expands tests to cover custom‐delimiter behavior
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/core.test.js | Adds and updates tests for custom‐delimiter support |
| src/util.ts | Extended getLines signature to accept delimiter |
| src/core.ts | Propagates delimiter option into process logic |
| build/util.cjs | Mirrors getLines change in compiled output |
| build/core.cjs | Mirrors core logic updates in compiled output |
| .size-limit.json | Bumps bundle size limits to account for new code |
| } | ||
| const bound: [string, string, Options][] = [] | ||
| const boundCtxs: [string, string, Options][] = [] | ||
| const delimiters: Array<string | RegExp | undefined> = [] |
Copilot
AI
Jun 3, 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.
Using a module‐scoped delimiters stack to manage per-call delimiters can lead to race conditions or mismatches when multiple outputs are processed concurrently. Consider storing the delimiter on each ProcessOutput or ProcessPromise instance instead of relying on shared mutable state.
| } | ||
|
|
||
| lines(): string[] { | ||
| lines(delimiter?: string | RegExp): string[] { |
Copilot
AI
Jun 3, 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.
[nitpick] The lines method currently pushes the passed delimiter into a global array before iterating, then pops it later. This pattern is error‐prone and hard to follow—encapsulate the delimiter on the instance rather than using a shared stack to improve clarity and reduce side effects.
lines()lines()
|
Does this resolve the issue? |
|
Yeah, sure! 👍 |
closes #1218