0.1.0 • Published 6 years ago
@gotoeasy/is-ignore v0.1.0
@gotoeasy/is-ignore
根据.gitignore文件的配置,判断指定文件或目录是否要忽略。
指定git仓库的文件目录即可,.gitignore文件将自动读取
Install
npm i @gotoeasy/is-ignoreAPI
const IsIgnore = require('@gotoeasy/is-ignore'): return the class ofis-ignorelet ignore = new IsIgnore(opts): create instanceopts.path: target directory.
ignore.isIgnore(file): returnstrueif pattern is ignored,falseotherwise.
Sample
D:/test/.gitignore
/node_modulesconst IsIgnore = require('@gotoeasy/is-ignore');
let ignore = new IsIgnore({path: 'D:/test'});
console.log(ignore.isIgnore('D:/test/README.md')); // false
console.log(ignore.isIgnore('D:/test/node_modules')); // trueNOTE
- 根目录有
.gitignore文件时将被利用并忽略相关文件,但解析匹配可能有搞错的情况
Links
npm-packageshttps://github.com/gotoeasy/npm-packages