gitignore-fs
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.0 • Public • Published

    gitignore-fs

    CircleCI Coverage Status semantic-release Commitizen friendly npm version

    Determine if any file is gitignored. This is intended to be a complete implementation of the gitignore spec, including $GIT_DIR, $GIT_DIR/info/excludes, and the core.excludesFile configuration variable.

    Requires Node >= 8.

    Getting started

    npm install --save gitignore-fs
    
    const Gitignore = require('gitignore-fs')
    
    const gitignore = new Gitignore()
    
    console.log(gitignore.ignores('node_modules')) // true or false depending on your config

    API

    class Gitignore

    Each instance of this class keeps a separate cache of gitignore rules.

    new Gitignore([options])

    Creates a new Gitignore instance.

    options.initialRules (string[], optional)

    These rules will be applied at lowest precedence (lower than rules from core.excludesFile). Paths with a slash in the beginning or middle are relative to the closest enclosing git directory.

    options.finalRules (string[], optional)

    These rules will be applied at highest precedence (higher than .gitignore files). Paths with a slash in the beginning or middle are relative to the closest enclosing git directory.

    .ignores(path)

    Determines if the given path is gitignored asynchronously.

    path (string, required)

    The path to test. Must end with / if it is a directory!

    Returns (Promise<boolean>)

    A promise that will resolve to true if path is gitignored, false otherwise

    .ignoresSync(path)

    Determines if the given path is gitignored synchronously.

    path (string, required)

    The path to test. Must end with / if it is a directory!

    Returns (boolean)

    true if path is gitignored, false otherwise

    .clearCache()

    Clears the entire gitignore rule cache.

    Keywords

    Install

    npm i gitignore-fs

    DownloadsWeekly Downloads

    5

    Version

    2.1.0

    License

    MIT

    Unpacked Size

    79.5 kB

    Total Files

    9

    Last publish

    Collaborators

    • jedwards1211