Skip to content

Commit

Permalink
fix: rename the functions to be more exact
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 18, 2021
1 parent 3cf37a1 commit d09ec83
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions lib/paths-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ export default class PathsCache extends EventEmitter {
/** @type {Promise<Array<Array<string>>} */
let result
try {
result = await this._buildInitialCacheWithGlob()
result = await this._cachePathsWithGlob()
} catch (e) {
console.error(e)
result = await this._buildInitialCacheWithAtom()
result = await this._cachePathsWithAtom()
}

this._addWatchers()
Expand Down Expand Up @@ -187,10 +187,10 @@ export default class PathsCache extends EventEmitter {
_onDirectoryChanged(projectDirectory, directory) {
this._removeFilePathsForDirectory(projectDirectory, directory)
this._cleanWatchersForDirectory(directory)
this._populateCacheWithGlob(directory.path).catch((e) => {
this._cachePathsForDirectoryWithGlob(directory.path).catch((e) => {
// fallback to Atom
console.error(e)
this._populateCacheWithAtom(projectDirectory, directory)
this._cachePathsForDirectoryWithAtom(projectDirectory, directory)
})
}

Expand Down Expand Up @@ -301,13 +301,13 @@ export default class PathsCache extends EventEmitter {
*/

/**
* Builds the initial file cache with `glob`
* Builds the file cache with `glob`
* @return {Promise<Array<Array<string>>}
* @private
*/
async _buildInitialCacheWithGlob() {
async _cachePathsWithGlob() {
const result = await Promise.all(
this._projectDirectories.map((projectDirectory) => this._populateCacheWithGlob(projectDirectory.path))
this._projectDirectories.map((projectDirectory) => this._cachePathsForDirectoryWithGlob(projectDirectory.path))
)
return result
}
Expand Down Expand Up @@ -372,7 +372,7 @@ export default class PathsCache extends EventEmitter {
* @return {Promise<Array<string>>}
* @private
*/
async _populateCacheWithGlob(directoryPath) {
async _cachePathsForDirectoryWithGlob(directoryPath) {
const directoryGlob = globifyDirectory(directoryPath)
const gitignoreGlob = await this._getGitIgnoreGlob(directoryPath)
const ignoredPatternsGlob = await this._getIgnoredPatternsGlob(directoryPath)
Expand All @@ -399,14 +399,14 @@ export default class PathsCache extends EventEmitter {
*/

/**
* Builds the initial file cache using Atom
* Builds the file cache using Atom
* @return {Promise<Array<Array<string>>}
* @private
*/
async _buildInitialCacheWithAtom() {
async _cachePathsWithAtom() {
const result = await Promise.all(
this._projectDirectories.map((projectDirectory) => {
return this._populateCacheWithAtom(projectDirectory, projectDirectory)
return this._cachePathsForDirectoryWithAtom(projectDirectory, projectDirectory)
})
)
return result
Expand All @@ -419,7 +419,7 @@ export default class PathsCache extends EventEmitter {
* @return {Promise}
* @private
*/
async _populateCacheWithAtom(projectDirectory, directory) {
async _cachePathsForDirectoryWithAtom(projectDirectory, directory) {
if (this._cancelled) return []

const entries = await this._getDirectoryEntries(directory)
Expand Down Expand Up @@ -459,6 +459,8 @@ export default class PathsCache extends EventEmitter {
filePathsArray = this._filePathsByDirectory.get(directory.path) || []
this._filePathsByDirectory.set(directory.path, union(filePathsArray, filePaths))

return Promise.all(directories.map((directory) => this._populateCacheWithAtom(projectDirectory, directory)))
return Promise.all(
directories.map((directory) => this._cachePathsForDirectoryWithAtom(projectDirectory, directory))
)
}
}

0 comments on commit d09ec83

Please sign in to comment.