dPay

.dwebignore

Check if a file should be ignored for a particular dPack:

  • Ignore .dpack by default
  • Use the .dpackignore file
  • Optionally ignore all hidden files
  • Add in other custom ignore matches

Install

npm install @dpack/ignore

Usage

var dpackIgnore = require('@dpack/ignore')
var ignore = dpackIgnore('/data/dir')

console.log(ignore('.dpack')) // true
console.log(ignore('.git')) // true
console.log(ignore('dpack-data')) // false
console.log(ignore('cat.jpg')) // false

Uses anymatch to match file paths.

Example Options

Common configuration options.

Add custom ignore

var ignore = dpackIgnore('/data/dir', {
    ignore: [
      '**/node_modules/**',
      'path/to/file.js',
      'path/anyjs/**/*.js'
    ]
  })

Allow Hidden Files

var ignore = dpackIgnore('/data/dir', { ignoreHidden: false })

Change dPack Ignore Path

var ignore = dpackIgnore('/data/dir', {
    dpackIgnorePath: '~/.dpackignore'
  })

.dpackignore as string/buffer

Pass in a string as a newline delimited list of things to ignore.

var dpackIgnoreFile = fs.readFileSync('~/.dpackignore')
dpackIgnoreFile += '\n' + fs.readFileSync(path.join(dir, '.dpackignore'))
dpackIgnoreFile += '\n' + fs.readFileSync(path.join(dir, '.gitignore'))

var ignore = dpackIgnore('/data/dir', { dpackignore: dpackIgnoreFile })

API

var ignore = dpackIgnore(dir, [opts])

Returns a function that checks if a path should be ignored:

ignore('.dpack') // true
ignore('.git') // true
ignore('data/cats.csv') // false

dir

dir is the file root to compare to. It is also used to find .dpackignore, if not specified.

Options:

  • opts.ignore - Extend custom ignore with any anymatch string or array.
  • opts.useDPackIgnore - Use the .dpackignore file in dir (default: true)
  • opts.ignoreHidden - Ignore all hidden files/folders (default: true)
  • opts.dpackignorePath - Path to .dpackignore file (default: dir/.dpackignore)
  • opts.dpackignore - Pass .dpackignore as buffer or string