is-subdir
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

is-subdir

Return whether a directory is a subdirectory of another directory

npm version

Cross-platform. Works correctly on Windows, where directory paths can start with disk drive letters in different casings. Like c:\foo and C:\foo\bar.

Returns true when the directories match. The isSubdir.strict() variant only returns true if the second parameter is a strict subdir of the first and not the same.

Installation

<npm|yarn|pnpm> add is-subdir

Usage

'use strict'
const path = require('path')
const isSubdir = require('is-subdir')

console.log(isSubdir(process.cwd(), path.resolve('node_modules')))
//> true
console.log(isSubdir.strict('node_modules/tape', '../tape'))
//> false

API

isSubdir(parentDir, subdir): boolean

isSubdir.strict(parentDir, subdir): boolean

License

MIT © Zoltan Kochan

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.2.0
    950,914
    • latest
  • 1.1.1
    3,522
    • next

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.2.0
    950,914
  • 1.1.1
    3,522
  • 1.0.3
    0
  • 1.0.2
    1
  • 1.0.1
    0
  • 1.0.0
    523

Package Sidebar

Install

npm i is-subdir

Weekly Downloads

954,960

Version

1.2.0

License

MIT

Unpacked Size

3.86 kB

Total Files

5

Last publish

Collaborators

  • zkochan