Skip to content

Commit

Permalink
fix: don't call rebuild-cache on file add or remove
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Apr 27, 2021
1 parent b191fc2 commit 022bfe8
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions lib/paths-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,16 @@ export default class PathsCache extends EventEmitter {
* @param addedFile {string}
*/
onAddFile(projectDirectory, addedFile) {
this.emit("rebuild-cache")
const filePaths = this._filePathsByProjectDirectory.get(projectDirectory.path)
filePaths.push(addedFile)
this._filePathsByProjectDirectory.set(projectDirectory.path, filePaths)
this.emit("rebuild-cache-done")
}

/**
* @param projectDirectory {Directory}
* @param removedFile {string}
*/
onRemoveFile(projectDirectory, removedFile) {
this.emit("rebuild-cache")
/** @type {string[]} */
const filePaths = this._filePathsByProjectDirectory.get(projectDirectory.path)

Expand All @@ -225,29 +222,24 @@ export default class PathsCache extends EventEmitter {
}
}
this._filePathsByProjectDirectory.set(projectDirectory.path, filePaths)
this.emit("rebuild-cache-done")
}

/**
* @param projectDirectory {Directory}
* @param addedDir {string}
*/
async onAddDir(projectDirectory, addedDir) {
this.emit("rebuild-cache")
const directory = new Directory(addedDir)
await this._cachePathsForDirectory(projectDirectory, directory)
this.emit("rebuild-cache-done")
}

/**
* @param projectDirectory {Directory}
* @param removedDir {string}
*/
onRemoveDir(projectDirectory, removedDir) {
this.emit("rebuild-cache")
const directory = new Directory(removedDir)
this._removeFilePathsForDirectory(projectDirectory, directory)
this.emit("rebuild-cache-done")
}

/**
Expand Down

0 comments on commit 022bfe8

Please sign in to comment.