0.3.2 • Published 6 years ago

ignore-to-acceptor v0.3.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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
0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago