@gotoeasy/is-ignore
v0.1.0
Published
按 .gitignore 文件配置的规则,判断是否为忽略的目录或文件
Downloads
4
Readme
@gotoeasy/is-ignore
根据.gitignore
文件的配置,判断指定文件或目录是否要忽略。
指定git仓库的文件目录即可,.gitignore
文件将自动读取
Install
npm i @gotoeasy/is-ignore
API
const IsIgnore = require('@gotoeasy/is-ignore')
: return the class ofis-ignore
let ignore = new IsIgnore(opts)
: create instanceopts.path
: target directory.
ignore.isIgnore(file)
: returnstrue
if pattern is ignored,false
otherwise.
Sample
D:/test/.gitignore
/node_modules
const 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')); // true
NOTE
- 根目录有
.gitignore
文件时将被利用并忽略相关文件,但解析匹配可能有搞错的情况
Links
npm-packages
https://github.com/gotoeasy/npm-packages