Summary
The function normalizeSlug(slug) is defined identically in 3 separate files. It should be moved to a shared utility and imported where needed.
Current Locations
src/commands/remove.js (lines 5-7)
src/commands/update.js (lines 8-10)
src/utils/installer.js (lines 6-8)
All three define: function normalizeSlug(slug) { return slug.replace(/\//g, "-") }
How to Fix
- Add
normalizeSlug to src/utils/lockfile.js (or a new src/utils/helpers.js) and export it
- Import it in
remove.js, update.js, and installer.js instead of defining it locally
- Remove the local definitions
- Run
npm test to verify
Why This Matters
Duplicated code means if the logic ever needs to change, it has to be updated in 3 places. A single source of truth is easier to maintain.
Difficulty
Easy — pure refactor, no behavior change.
Files
src/commands/remove.js
src/commands/update.js
src/utils/installer.js
src/utils/lockfile.js (or new file)
Summary
The function
normalizeSlug(slug)is defined identically in 3 separate files. It should be moved to a shared utility and imported where needed.Current Locations
src/commands/remove.js(lines 5-7)src/commands/update.js(lines 8-10)src/utils/installer.js(lines 6-8)All three define:
function normalizeSlug(slug) { return slug.replace(/\//g, "-") }How to Fix
normalizeSlugtosrc/utils/lockfile.js(or a newsrc/utils/helpers.js) and export itremove.js,update.js, andinstaller.jsinstead of defining it locallynpm testto verifyWhy This Matters
Duplicated code means if the logic ever needs to change, it has to be updated in 3 places. A single source of truth is easier to maintain.
Difficulty
Easy — pure refactor, no behavior change.
Files
src/commands/remove.jssrc/commands/update.jssrc/utils/installer.jssrc/utils/lockfile.js(or new file)