Skip to content

Commit

Permalink
Memoize findNpmConfig per path.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Apr 5, 2023
1 parent 83ff962 commit 1677619
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/package-managers/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const normalizeNpmConfig = (
}

/** Finds and parses the npm config at the given path. If the path does not exist, returns null. If no path is provided, finds and merges the global and user npm configs using libnpmconfig and sets cache: false. */
const findNpmConfig = (configPath?: string): NpmConfig | null => {
const findNpmConfig = memoize((configPath?: string): NpmConfig | null => {
let config

if (configPath) {
Expand All @@ -193,7 +193,7 @@ const findNpmConfig = (configPath?: string): NpmConfig | null => {
}

return normalizeNpmConfig(config, configPath)
}
})

// get the base config that is used for all npm queries
// this may be partially overwritten by .npmrc config files when using --deep
Expand Down

0 comments on commit 1677619

Please sign in to comment.