Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"scripts": {
"build": "pnpm dev:prepare && pnpm build:module && pnpm build:discovery && pnpm build:client",
"build:client": "nuxi generate client && cp -r client/.output/public/ dist/client/",
"build:client": "nuxi generate client && node -e \"require('fs').cpSync('client/.output/public','dist/client',{recursive:true})\"",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In Node.js, for fs.cpSync(src, dest, { recursive: true }), if destalready exists, are files indestthat are absent fromsrc removed or left in place?

💡 Result:

Files in dest that are absent from src are left in place. fs.cpSync(src, dest, { recursive: true }) copies the contents of src into dest (creating dest if it doesn't exist), overwriting files that exist in both, but does not delete files or directories in dest that are not present in src. This matches the behavior of the Unix cp -r src dest/ command, which the Node.js documentation explicitly compares it to: "behavior is similar to cp dir1/ dir2/". Standard cp -r (or cp -a) merges directories without removing extra files in the destination.

Citations:


Clear dist/client before copying to prevent stale cached artifacts.

The fs.cpSync() call copies files into dist/client without removing prior contents. Since removed files in the source are not deleted from the destination, and Turbo caches dist/** across builds, missing files can persist in the output, making builds non-deterministic.

Proposed fix
-    "build:client": "nuxi generate client && node -e \"require('fs').cpSync('client/.output/public','dist/client',{recursive:true})\"",
+    "build:client": "nuxi generate client && node -e \"const fs=require('fs');fs.rmSync('dist/client',{recursive:true,force:true});fs.cpSync('client/.output/public','dist/client',{recursive:true})\"",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"build:client": "nuxi generate client && node -e \"require('fs').cpSync('client/.output/public','dist/client',{recursive:true})\"",
"build:client": "nuxi generate client && node -e \"const fs=require('fs');fs.rmSync('dist/client',{recursive:true,force:true});fs.cpSync('client/.output/public','dist/client',{recursive:true})\"",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/devtools/package.json` at line 36, The npm script "build:client"
uses node -e
"require('fs').cpSync('client/.output/public','dist/client',{recursive:true})"
which copies into dist/client without removing prior contents; update the script
to remove/clear the destination first (e.g., call
require('fs').rmSync('dist/client',{recursive:true,force:true}) or equivalent)
before invoking cpSync so stale files are removed and the output is
deterministic; ensure the removal runs only for that path and still preserves
error/exit behavior of the script.

"build:module": "nuxt-build-module build",
"build:discovery": "npx discovery-build -c .discoveryrc.cjs -s -o client/public/discovery",
"dev:discovery": "discovery -c .discoveryrc.cjs",
Expand Down
Loading