fix(setup): remove duplicate dev paths in plugin-setup#1943
fix(setup): remove duplicate dev paths in plugin-setup#1943Yeachan-Heo merged 1 commit intoYeachan-Heo:devfrom
Conversation
The devPaths array in the generated HUD wrapper script had 4 entries where entries 3-4 were exact duplicates of entries 1-2 (Workspace and workspace variants). Removed the 2 duplicate lines. Confidence: high Scope-risk: narrow
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
There was a problem hiding this comment.
Pull request overview
Removes duplicate devPaths entries from the HUD wrapper script template embedded in scripts/plugin-setup.mjs, and adds a regression test to prevent reintroducing duplicates.
Changes:
- Removed two duplicate
devPathsentries in the generatedomc-hud.mjswrapper script template. - Added a Vitest regression test to assert
devPathsis deduplicated and retains bothWorkspace/workspacevariants.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/plugin-setup.mjs | Removes duplicate development path entries in the embedded HUD wrapper script template. |
| src/tests/plugin-setup-devpaths.test.ts | Adds regression coverage to detect duplicate devPaths entries and ensure both case variants remain present. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| describe('plugin-setup.mjs devPaths deduplication', () => { | ||
| const scriptContent = existsSync(PLUGIN_SETUP_PATH) | ||
| ? readFileSync(PLUGIN_SETUP_PATH, 'utf-8') | ||
| : ''; | ||
|
|
||
| it('script file exists', () => { | ||
| expect(existsSync(PLUGIN_SETUP_PATH)).toBe(true); | ||
| }); |
There was a problem hiding this comment.
scriptContent is computed at describe-time with a '' fallback when the file is missing. If scripts/plugin-setup.mjs is absent, the later tests will still run against the empty string and fail with less-informative match/assertion errors in addition to the existence check. Consider reading the file in a beforeAll (or inside each test) after asserting the file exists, and fail fast if it doesn't.
| .filter(line => line.startsWith('join(')); | ||
|
|
||
| // Verify no duplicates |
There was a problem hiding this comment.
The duplicate check compares raw trimmed source lines (new Set(pathEntries)), so duplicates with different formatting (e.g., whitespace differences, trailing comments, or a missing comma) would not be detected even though the resulting devPaths entries are duplicates. To make this regression test robust, extract/normalize the actual path string argument(s) from each join(...) entry before de-duplicating.
| .filter(line => line.startsWith('join(')); | |
| // Verify no duplicates | |
| .filter(line => line.startsWith('join(')) | |
| .map(line => { | |
| // Normalize by extracting all string literal arguments to join(...) | |
| const argsMatch = line.match(/join\((.*)\)/); | |
| if (!argsMatch) { | |
| return line; | |
| } | |
| const argContent = argsMatch[1]; | |
| const stringLiterals = Array.from( | |
| argContent.matchAll(/(['"`])([^'"`]*?)\1/g) | |
| ).map(match => match[2]); | |
| // Use concatenated string literals as a stable key; fall back to a | |
| // whitespace-normalized argument list if no literals are present. | |
| if (stringLiterals.length > 0) { | |
| return stringLiterals.join('|'); | |
| } | |
| return argContent.replace(/\s+/g, ''); | |
| }); | |
| // Verify no duplicates in normalized entries |
Bug
The
devPathsarray in the generated HUD wrapper script (omc-hud.mjs) insidescripts/plugin-setup.mjshad 4 entries where entries 3-4 were exact duplicates of entries 1-2:Fix
Removed the 2 duplicate lines. The array now contains only the 2 unique entries (capital
Workspaceand lowercaseworkspacevariants).Test
Added
src/__tests__/plugin-setup-devpaths.test.tswith regression tests that:devPathsarray has no duplicate entriesWorkspaceandworkspacevariants are still presentCI
npx tsc --noEmit— 0 errorsnpx vitest run— 7084 passed, 7 skippednpm run build— success