Skip to content

fix: make fix and the unused-dependency fallback work on Windows - #12

Open
AjayBThorat-20 wants to merge 1 commit into
fix/cli-output-bugsfrom
fix/windows-support
Open

AjayBThorat-20 wants to merge 1 commit into
fix/cli-output-bugsfrom
fix/windows-support

Conversation

@AjayBThorat-20

@AjayBThorat-20 AjayBThorat-20 commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

What and why

  • fix couldn't install or remove anything on Windows. It ran execFileSync('npm', …), and Node can't start npm.cmd without a shell. npm calls now go through cross-spawn, which resolves npm/npm.cmd everywhere and still passes arguments without a shell; npm audit uses the same helper.
  • The unused-dependency fallback reported nothing on Windows. It shelled out to grep. It's a JavaScript scan now, covering imports in code and whole-name references in config files and stylesheets (.babelrc, postcss.config.js, @import), and it no longer counts a substring (ms inside items) as a use.
  • knip runs from DevCompass's own bundled copy instead of npx knip, which resolved it against the scanned project and could download a different version.

cross-spawn was already installed transitively; the lockfile is unchanged. This should let the Windows CI job (#7) drop continue-on-error.

Stacked on #11.

Merging the stack: use Create a merge commit, not squash (squashing makes every later PR show these commits again). After merging the PR below this one, click Delete branch on it; GitHub then retargets this PR to main and CI runs.

How I tested it

  • npm run test:coverage on Node 24.21.0, clean npm ci, network disabled: 127/127 pass, 36.33% lines
  • npm audit --audit-level=high currently fails on GHSA-mrwp-f3q8-3g9p (follow-redirects, published after this branch was made); the lockfile fix is in feat: rank vulnerabilities by exploit risk (CISA KEV + FIRST EPSS) #14
  • Unit tests for runNpm (no shell, npm.cmd resolution) and the JavaScript unused scan (config files, stylesheets, no substring matches)

🤖 Generated with Claude Code

- fix ran execFileSync('npm', ...), which can't start npm.cmd on Windows
  (Node won't spawn a .cmd without a shell), so it could not install or
  remove anything there. npm calls now go through cross-spawn (runNpm),
  which resolves npm/npm.cmd and passes arguments without a shell; npm
  audit uses the same helper.
- The unused fallback shelled out to grep, which Windows lacks, so every
  dependency looked used. It is a JavaScript scan now: imports in code,
  whole-name references in config files and stylesheets (.babelrc,
  postcss.config.js, @import), and no longer a bare substring match.
- Run DevCompass's own bundled knip instead of `npx knip`, which resolved
  knip against the scanned project and could download another version.

cross-spawn was already installed transitively; the lockfile is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant