Skip to content

DistributedWeb/dwebx-ignore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dwebx-ignore

default ignore for dwebx

npm travis standard

Check if a file should be ignored for DWebX:

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

Install

npm install dwebx-ignore

Usage

var dwebxIgnore = require('dwebx-ignore')
var ignore = dwebxIgnore('/data/dir')

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

Uses anymatch to match file paths.

Example Options

Common configuration options.

Add custom ignore

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

Allow Hidden Files

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

Change DWebX Ignore Path

var ignore = dwebxIgnore('/data/dir', {
    dwebxignorePath: '~/.dwebxignore'
  })

.dwebxignore as string/buffer

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

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

var ignore = dwebxIgnore('/data/dir', { dwebxignore: dwebxIgnoreFile })

API

var ignore = dwebxIgnore(dir, [opts])

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

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

dir

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

Options:

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

License

MIT

About

DEPRECATED LEGACY DWEB MODULE

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •