-
Notifications
You must be signed in to change notification settings - Fork 0
ƒeat: dev deps support #31
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 improved support for dev dependencies when running lnpm add, including preserving devDependencies placement for packages that are already listed there.
Changes:
- Update
updatePackageJSONto selectdevDependencieswhen appropriate and remove duplicate entries across dependency fields. - Add a regression test ensuring
lnpm add(and no--dev) keeps an existing dev dependency indevDependencies. - Adjust progress-line clearing spacing in pack/store workflows.
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/add_test.go |
Adds coverage for preserving devDependencies location when re-adding without --dev. |
internal/cli/add.go |
Implements dependency-field selection logic and de-duplication when updating package.json. |
internal/store/store.go |
Tweaks console progress-line clearing width after large operations. |
internal/pack/pack.go |
Tweaks console progress-line clearing width after large scans. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| data, _ = os.ReadFile(pkgJSONPath) | ||
| var result map[string]interface{} | ||
| json.Unmarshal(data, &result) | ||
|
|
||
| deps := result["dependencies"] | ||
| devDeps := result["devDependencies"].(map[string]interface{}) |
Copilot
AI
Jan 23, 2026
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 test ignores the error from json.Unmarshal and then does an unchecked type assertion on result["devDependencies"]. If package.json can't be read/parsed, this can panic and obscure the real failure. Please check the ReadFile/Unmarshal errors and guard the type assertion (or reuse the existing helper accessors used elsewhere in tests).
| data, _ = os.ReadFile(pkgJSONPath) | |
| var result map[string]interface{} | |
| json.Unmarshal(data, &result) | |
| deps := result["dependencies"] | |
| devDeps := result["devDependencies"].(map[string]interface{}) | |
| data, err := os.ReadFile(pkgJSONPath) | |
| if err != nil { | |
| t.Fatalf("Failed to read package.json: %v", err) | |
| } | |
| var result map[string]interface{} | |
| if err := json.Unmarshal(data, &result); err != nil { | |
| t.Fatalf("Failed to unmarshal package.json: %v", err) | |
| } | |
| deps := result["dependencies"] | |
| devDepsVal, ok := result["devDependencies"] | |
| if !ok { | |
| t.Fatalf("package.json missing devDependencies field") | |
| } | |
| devDeps, ok := devDepsVal.(map[string]interface{}) | |
| if !ok { | |
| t.Fatalf("devDependencies has unexpected type: %T", devDepsVal) | |
| } |
|
|
||
| // Determine which field to use: | ||
| // - If --dev flag: use devDependencies | ||
| // - Else if package exists in devDependencies: use devDependencies (preserve location) |
Copilot
AI
Jan 23, 2026
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 comment says “if package exists in devDependencies: use devDependencies (preserve location)”, but the condition only preserves devDependencies when the package is NOT also in dependencies (!inDeps && inDevDeps). Either adjust the condition to match the documented behavior, or update the comment to reflect the actual precedence when a package appears in both fields.
| // - Else if package exists in devDependencies: use devDependencies (preserve location) | |
| // - Else if package exists only in devDependencies (and not in dependencies): use devDependencies |
No description provided.