Conversation
Co-authored-by: toolate28 <105518313+toolate28@users.noreply.github.com>
Signed-off-by: toolated <toolated@toolated.online>
There was a problem hiding this comment.
Pull request overview
This pull request aims to enhance the safety of the dependency installation process by improving path validation before removing the node_modules directory during forced reinstallation. The change replaces a simple string suffix check with absolute path resolution and comparison.
Changes:
- Added
resolveimport from thepathmodule to support absolute path resolution - Replaced
endsWith("node_modules")validation with absolute path comparison usingresolve()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Validate path before removal for safety - ensure it resolves to expected location | ||
| const resolvedPath = resolve(nodeModulesPath); |
There was a problem hiding this comment.
The comparison between resolvedPath and expectedPath is redundant. Since nodeModulesPath is already defined as join(ROOT_DIR, "node_modules") on line 101, calling resolve(nodeModulesPath) and resolve(ROOT_DIR, "node_modules") will always produce identical results. Both expressions are computing the same absolute path from the same inputs.
A more meaningful safety check would validate that the resolved path is within the project directory or matches a specific pattern, rather than comparing two computations of the same value.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
This pull request makes a small but important improvement to the dependency installation process in the
scripts/setup.tsfile. The main change enhances the safety check before removing thenode_modulesdirectory during a forced reinstall.Safety improvements for dependency installation:
node_modulesnow usesresolve()to ensure the directory being deleted is exactly the intended one, reducing the risk of accidental deletion of the wrong folder.resolveimport frompathto support the improved path validation.