Skip to content

Conversation

@sinisterstumble
Copy link
Contributor

@sinisterstumble sinisterstumble commented May 13, 2024

Closes #634

@webpro
Copy link
Member

webpro commented May 14, 2024

Thanks @markmartirosian. Yeah let's try a try-catch, this feels a bit redundant.

@sinisterstumble
Copy link
Contributor Author

@webpro done

Copy link
Member

@webpro webpro left a comment

Choose a reason for hiding this comment

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

I meant try-catch only at the new call-site, here it's not necessary with the no-throw options

@sinisterstumble
Copy link
Contributor Author

@webpro isn't this scenario general? Here's an illustration, '.profile' is a regular file.

> const fs = require('fs')
> fs.statSync('.profile/excludes', { throwIfNoEntry: false })
Uncaught Error: ENOTDIR: not a directory, stat '.profile/excludes'
    at Object.statSync (node:fs:1659:25) {
  errno: -20,
  code: 'ENOTDIR',
  syscall: 'stat',
  path: '.profile/excludes'
}

@webpro
Copy link
Member

webpro commented May 15, 2024

Isn't it odd, are we being lied to by throwIfNoEntry: false? I guess you're not on a Node version that does not support that option yet?

Then we could just do without this option?

@sinisterstumble
Copy link
Contributor Author

@webpro yes very unexpected, I'm on v21.7.1 and given the versions in the screenshot this seems to be the intended behavior.

Screenshot 2024-05-15 at 17 34 09

@sinisterstumble
Copy link
Contributor Author

@webpro made the changes

@webpro webpro merged commit dabccf1 into webpro-nl:main May 15, 2024
@webpro
Copy link
Member

webpro commented May 15, 2024

Thanks @markmartirosian! Good stuff.

@sinisterstumble sinisterstumble deleted the fix/is-file-is-directory-edge-cases branch May 15, 2024 16:10
@webpro
Copy link
Member

webpro commented May 22, 2024

🚀 This pull request is included in v5.17.0-canary.0. See Release 5.17.0-canary.0 for release notes.

Using Knip in a commercial project? Please consider sponsoring me.

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.

5.14.0 breaks knip in git submodules

2 participants