zkochan / packages

Zoltan Kochan's npm packages
MIT License
99 stars 26 forks source link

Please implement isProperSubdir() #123

Closed rulatir closed 3 years ago

rulatir commented 3 years ago

[edited to revise the request in light of correct understanding of the current behavior]

As per title, please implement isProperSubdir() which would only return true if the second parameter is a proper subdirectory of the first but not the same. This should be in the library because it should use the same path normalization/resolution strategy as the original function.

Alternatively we could add an optional boolean third argument to turn on the !== check, defaulting to false.

Implementation should be trivial and I could submit a PR, but please decide on the API variant.

zkochan commented 3 years ago

isSubdir already works as isSubdirOrSame

rulatir commented 3 years ago

Thanks for a prompt response. I revised my request.

zkochan commented 3 years ago

I'd probably name it isSubdirStrict

or maybe we can make a breaking change and add isSubdirOrSame

rulatir commented 3 years ago

Did a preliminary PR subject to further commits, but really all the work is in deciding how to name things.

rulatir commented 3 years ago

The solution I propose makes it possible to access the new API without modifying the import/require statement. I add the reference to the new function as a property of the old function. Usage:

const isSubdir = require('is-subdir');

if (isSubdir.proper(dir1, dir2)) {
   //...
}

Rename to strict?

zkochan commented 3 years ago

ok

rulatir commented 3 years ago

A sec to update README.md and tests...

rulatir commented 3 years ago

PR ready with updated test, README.md and is-subdir/index.d.ts.

zkochan commented 3 years ago

ok, but you need to submit the PR to this repo

rulatir commented 3 years ago

Oops. Making this mistake every. Goddamn. Time.

124 is ready. macOS CI jobs seem to require maintenance.

zkochan commented 3 years ago

published