-
Notifications
You must be signed in to change notification settings - Fork 47
fix: use temp directory for jscpd output on Windows (#270) #271
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |||||||||
| */ | ||||||||||
|
|
||||||||||
| const { execSync, execFileSync } = require('child_process'); | ||||||||||
| const os = require('os'); | ||||||||||
| const path = require('path'); | ||||||||||
| const fs = require('fs'); | ||||||||||
| // Note: escapeDoubleQuotes no longer needed - using execFileSync with arg arrays | ||||||||||
|
|
@@ -345,16 +346,20 @@ function runDuplicateDetection(repoPath, options = {}) { | |||||||||
| const minLines = options.minLines || 5; | ||||||||||
| const minTokens = options.minTokens || 50; | ||||||||||
|
|
||||||||||
| // Use temp directory for jscpd output to avoid platform-specific null device issues. | ||||||||||
| // On Windows, NUL passed via execFileSync (no shell) is treated as a literal filename, | ||||||||||
| // creating a mangled path in the working directory. | ||||||||||
|
Comment on lines
+350
to
+351
|
||||||||||
| // On Windows, NUL passed via execFileSync (no shell) is treated as a literal filename, | |
| // creating a mangled path in the working directory. | |
| // jscpd interprets the value passed to --output itself, so using NUL or /dev/null here | |
| // results in jscpd creating a mangled path on Windows rather than discarding the output. |
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.
These tests spy on
fs.rmSyncbut also mock it to a no-op. SincerunDuplicateDetection()uses a realfs.mkdtempSync(), this can leave real temp directories behind on disk (cleanup runs but is stubbed). Prefer spying without overriding implementation (call-through), or ensure the created temp dir is actually removed in test teardown.