Skip to content

Commit

Permalink
refactor: use set instead of array
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeanroy committed Mar 10, 2024
1 parent 4d1282c commit d7db768
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/license-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ class LicensePlugin {
let dir = path.resolve(path.parse(id).dir);
let pkg = null;

const scannedDirs = [];
const scannedDirs = new Set();

this.debug(`iterative over directory tree, starting with: ${dir}`);

while (dir && dir !== this._cwd && !scannedDirs.includes(dir)) {
while (dir && dir !== this._cwd && !scannedDirs.has(dir)) {
// Try the cache.
if (this._cache.has(dir)) {
pkg = this._cache.get(dir);
Expand All @@ -170,7 +170,7 @@ class LicensePlugin {
break;
}

scannedDirs.push(dir);
scannedDirs.add(dir);

this.debug(`looking for package.json file in: ${dir}`);
const pkgPath = path.join(dir, 'package.json');
Expand Down

0 comments on commit d7db768

Please sign in to comment.