is-subdir
Return whether a directory is a subdirectory of another directory
Last updated 5 years ago by zkochan .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install is-subdir 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.2.0                                ...           latest (5 years ago)
  • 1.1.1                                ...           next (7 years ago)

6 Versions

  • 1.2.0                                ...           5 years ago
  • 1.1.1                                ...           7 years ago
  • 1.0.3                                ...           7 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago

Copyright 2013 - present © cnpmjs.org | Home |