🐛 Exclude files in hidden folder
This commit is contained in:
+1
@@ -0,0 +1 @@
|
|||||||
|
This file shouldn't be include
|
||||||
+19
-24
@@ -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 ) =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user