Comparing version
'use strict' | ||
const betterPathResolve = require('better-path-resolve') | ||
const path = require('path') | ||
module.exports = function (parent, dir) { | ||
const rParent = betterPathResolve(parent) | ||
const rDir = betterPathResolve(dir) | ||
module.exports = function isSubdir (parentDir, subdir) { | ||
const rParent = `${betterPathResolve(parentDir)}${path.sep}` | ||
const rDir = `${betterPathResolve(subdir)}${path.sep}` | ||
return rDir.startsWith(rParent) | ||
} |
{ | ||
"name": "is-subdir", | ||
"version": "1.0.3", | ||
"description": "Return whether a directory is a subdirectory of another directory", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js" | ||
], | ||
"scripts": { | ||
"test": "mos t && node test", | ||
"md": "mos" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"repository": "https://github.com/zkochan/packages/tree/master/is-subdir", | ||
"keywords": [ | ||
"subdirectory", | ||
"subfolder", | ||
"subpath", | ||
"directory", | ||
"folder", | ||
"path" | ||
], | ||
"author": { | ||
"name": "Zoltan Kochan", | ||
"url": "https://www.kochan.io" | ||
}, | ||
"mos": { | ||
"plugins": [ | ||
"readme" | ||
], | ||
"installation": { | ||
"useShortAlias": true | ||
} | ||
}, | ||
"license": "MIT", | ||
"homepage": "https://github.com/zkochan/packages/tree/master/is-subdir#readme", | ||
"devDependencies": { | ||
"is-windows": "1.0.2", | ||
"mos": "^2.0.0-alpha.3", | ||
"mos-plugin-readme": "^1.0.4", | ||
"tape": "^4.6.3" | ||
}, | ||
"dependencies": { | ||
"better-path-resolve": "1.0.0" | ||
} | ||
"name": "is-subdir", | ||
"version": "1.1.1", | ||
"description": "Return whether a directory is a subdirectory of another directory", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"scripts": { | ||
"test": "node test", | ||
"md": "mos" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"repository": "https://github.com/zkochan/packages/tree/master/is-subdir", | ||
"keywords": [ | ||
"subdirectory", | ||
"subfolder", | ||
"subpath", | ||
"directory", | ||
"folder", | ||
"path" | ||
], | ||
"author": { | ||
"name": "Zoltan Kochan", | ||
"url": "https://www.kochan.io" | ||
}, | ||
"mos": { | ||
"plugins": [ | ||
"readme" | ||
], | ||
"installation": { | ||
"useShortAlias": true | ||
} | ||
}, | ||
"license": "MIT", | ||
"homepage": "https://github.com/zkochan/packages/tree/master/is-subdir#readme", | ||
"devDependencies": { | ||
"is-windows": "1.0.2", | ||
"mos": "^2.0.0-alpha.3", | ||
"mos-plugin-readme": "^1.0.4", | ||
"tape": "^4.6.3" | ||
}, | ||
"dependencies": { | ||
"better-path-resolve": "1.0.0" | ||
} | ||
} |
@@ -11,6 +11,8 @@ # is-subdir | ||
Returns `true` when the directories match. | ||
## Installation | ||
```sh | ||
npm i -S is-subdir | ||
<npm|yarn|pnpm> add is-subdir | ||
``` | ||
@@ -29,4 +31,8 @@ | ||
## API | ||
### `isSubdir(parentDir, subdir): boolean` | ||
## License | ||
[MIT](./LICENSE) © [Zoltan Kochan](https://www.kochan.io) |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3192
7.84%5
25%10
42.86%37
19.35%