cli icon indicating copy to clipboard operation
cli copied to clipboard

fix: don't mkdir directories that already exist

Open TheCSDev opened this issue 1 year ago • 3 comments

This pull request aims to resolve #6412, by making checks for whether a project's working directory already exists, before attempting to mkdir it.
This effectively prevents reify.js from accidentally executing mkdir on root drive letters on Windows, like mkdir "D:/" for example, as the Windows operating system prohibits such operations.

The resolution of #6412 will inevitably introduce the npm error Tracker "idealTree" already exists issue, however I believe that is an issue separate from #6412, and that separate issue was already documented before, #7596 being a good example of one of those documentations (in my opinion).

As can be seen in #6412, this pull request makes changes to the following line of code in reify.js.

Of course, should one attempt to execute npm i in a drive letter that does not exist, then this error in my opinion should take place, informing the user that said drive letter and the path within cannot be created, and that error will take place. However this error in my opinion should not take place on existing drives, hence this pull request.

Additional info

  • Affected file: /workspaces/arborist/lib/arborist/reify.js line 126
  • Relevant issue: #6412
  • Other related issues/prs: #7596

TheCSDev avatar Nov 09 '24 09:11 TheCSDev

npm run lintfix should fix linting errors.

wraithgar avatar Nov 21 '24 15:11 wraithgar

Ah, it appears I accidentally used double-quotes instead of single-quotes for the string.
Also for some reason npm run lintfix did not spot any errors or make any "fixing" changes for me, so it took a bit of figuring out. I eventually found the npm run lint -w @npmcli/arborist command from a GitHub Workflows task, and that one was able to spot the syntax error I made.
I will now make one more commit to correct that error, and hopefully that should be it. Thank you for helping me.

TheCSDev avatar Nov 21 '24 17:11 TheCSDev

Oh shoot, sorry I forgot this was the cli repo. Yeah you gotta either be in the arborist directory or specify the workspace. I'll have to remember that when suggesting that in the future.

wraithgar avatar Nov 21 '24 18:11 wraithgar