ignore-to-acceptor
turn .gitignore's pattern to acceptor function.
Last updated 3 years ago by lemon-clown .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ignore-to-acceptor 
SYNC missed versions from official npm registry.

ignoreToAcceptor

ignoreToAcceptor can filter a file/directory(name, not content) consistent with the .gitignore rules. ignoreToAcceptor received variable parameter consist of { string|string[] }, and return an object with three functions.

  • fileAccepted(filename: string)=> boolean: check whether a filename will be accepted under the given ignore patterns.
  • dirAccepted(filename: string)=> boolean: check whether a dirname will be accepted under the given ignore patterns.
  • accepted(name: string, isDir: boolean)=> boolean:
    • name: file/directory name
    • isDir: the name gived previous whether or not represent a dir.
    • return true if it's accepted under the given ignore patterns.

Noticed that build/ will not matched a file named build, so that is important to distinguish the incoming parameter is a directory or file.

USAGE

import { ignoreToAcceptor } from 'ignore-to-acceptor'


let ignorePatterns = [
  'build/*',
  '!build/config.xml',
]
let acceptor = ignoreToAcceptor(ignorePatterns)
// or let acceptor = ignoreToAcceptor(...ignorePatterns)

acceptor.fileAccepted('build/config.xml')   // true
acceptor.fileAccepted('build/a')            // false
acceptor.dirAccepted('build')               // true

Current Tags

  • 0.3.2                                ...           latest (2 years ago)

10 Versions

  • 0.3.2                                ...           2 years ago
  • 0.3.1                                ...           2 years ago
  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
  • 0.0.5                                ...           3 years ago
  • 0.0.4                                ...           3 years ago
  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 2
Last Month 4
Dependencies (1)
Dev Dependencies (8)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |