🐛 Exclude files in hidden folder

This commit is contained in:
brunosimon
2016-11-21 13:47:31 +01:00
parent 107c96fa54
commit e2f6f2f822
2 changed files with 20 additions and 24 deletions
+1
View File
@@ -0,0 +1 @@
This file shouldn't be include
+19 -24
View File
@@ -79,11 +79,30 @@ class Watcher
*/ */
set_watcher() set_watcher()
{ {
// Create ignored regex
let regexs = [],
Minimatch = require( 'minimatch' ).Minimatch
for( let _exclude_key in this.options.exclude )
{
let _exclude = this.options.exclude[ _exclude_key ],
minimatch = new Minimatch( _exclude, { dot: true } ),
regex = '' + minimatch.makeRe()
regex = regex.replace( '/^', '' )
regex = regex.replace( '$/', '' )
regexs.push( regex )
}
let regex = new RegExp( regexs.join( '|' ) )
// Set up // Set up
this.watcher = chokidar.watch( this.watcher = chokidar.watch(
process.cwd(), process.cwd(),
{ {
// ignored : /[\/\\]\./, // ignored : /[\/\\]\./,
ignored : regex,
ignoreInitial: true ignoreInitial: true
} }
) )
@@ -105,18 +124,6 @@ class Watcher
file.can_read = false file.can_read = false
} }
// Test exclusion
for( let _exclude_key in this.options.exclude )
{
// Set up
let _exclude = this.options.exclude[ _exclude_key ],
relative_path = _path.replace( process.cwd() + '/', '' )
// Match excluded path
if( minimatch( relative_path, _exclude ) )
return
}
// Retrieve stats // Retrieve stats
fs.stat( _path, ( error, stats ) => fs.stat( _path, ( error, stats ) =>
{ {
@@ -159,18 +166,6 @@ class Watcher
file.can_read = false file.can_read = false
} }
// Test exclusion
for( let _exclude_key in this.options.exclude )
{
// Set up
let _exclude = this.options.exclude[ _exclude_key ],
relative_path = _path.replace( process.cwd() + '/', '' )
// Match excluded path
if( minimatch( relative_path, _exclude ) )
return
}
// Retrieve stats // Retrieve stats
fs.stat( _path, ( error, stats ) => fs.stat( _path, ( error, stats ) =>
{ {