Skip to content

Commit c72608d

Browse files
authored
Merge pull request #269 from atom-community/ignoreglob-by-project
2 parents 645ba59 + ef98d40 commit c72608d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/paths-cache.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class PathsCache extends EventEmitter {
2323
this._filePathsByProjectDirectory = new Map()
2424
this._filePathsByDirectory = new Map()
2525
this._fileWatchersByDirectory = new Map()
26-
this._allIgnoredGlob = []
26+
this._allIgnoredGlobByDirectory = new Map()
2727
this.updateConfig()
2828
}
2929

@@ -175,14 +175,17 @@ export default class PathsCache extends EventEmitter {
175175
}
176176
// add a watcher to run `this._onDirectoryChanged`
177177
const projectPath = projectDirectory.getPath()
178-
const ignored = this._allIgnoredGlob
178+
const ignored = this._allIgnoredGlobByDirectory.get(projectDirectory.path)
179179
// TODO smarter handling of directory changes
180180
// TODO get paths from the watcher itself
181181
// TODO track gitignore file
182182
watcher = chokidar
183183
.watch([projectPath, ...ignored], {
184184
persistent: true,
185185
ignoreInitial: true, // do not run the listeners on the initial scan
186+
followSymlinks: false,
187+
interval: 1000,
188+
binaryInterval: 1000,
186189
})
187190
.on("add", (addedFile) => {
188191
// we should track it too!
@@ -198,7 +201,7 @@ export default class PathsCache extends EventEmitter {
198201
this.onRemoveFile(projectDirectory, removedFile)
199202
})
200203
.on("addDir", (addedDir) => {
201-
this.onAddDir(projectDirectory, addedDir)
204+
this.onAddDir(addedDir)
202205
})
203206
.on("unlinkDir", (removedDir) => {
204207
this.onRemoveDir(projectDirectory, removedDir)
@@ -231,10 +234,9 @@ export default class PathsCache extends EventEmitter {
231234
}
232235

233236
/**
234-
* @param projectDirectory {Directory}
235237
* @param addedDir {string}
236238
*/
237-
async onAddDir(projectDirectory, addedDir) {
239+
async onAddDir(addedDir) {
238240
await this._cachePathsForDirectoryWithGlob(addedDir)
239241
}
240242

@@ -484,9 +486,10 @@ export default class PathsCache extends EventEmitter {
484486
*/
485487
async _cachePathsForDirectoryWithGlob(directoryPath) {
486488
const directoryGlob = globifyDirectory(directoryPath)
487-
this._allIgnoredGlob = await this._getAllIgnoredGlob(directoryPath)
489+
const allIgnoredGlob = await this._getAllIgnoredGlob(directoryPath)
490+
this._allIgnoredGlobByDirectory.set(directoryPath, allIgnoredGlob)
488491
const files = await glob(
489-
[directoryGlob, ...this._allIgnoredGlob],
492+
[directoryGlob, ...allIgnoredGlob],
490493
// glob options
491494
{
492495
dot: true,

0 commit comments

Comments
 (0)