Skip to content

Commit

Permalink
fix: lazy load of which module (#176)
Browse files Browse the repository at this point in the history
Currently `@npmcli/git` is eagerly getting and caching the `git` path in
a user's system which can have a significant performance cost when
requiring `@npmcli/git`. This PR avoids this cost by lazily getting &
caching `git` path on first use.
  • Loading branch information
thecodrr committed Dec 19, 2023
1 parent 46192f5 commit c398872
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const spawn = require('@npmcli/promise-spawn')
const promiseRetry = require('promise-retry')
const log = require('proc-log')
const makeError = require('./make-error.js')
const whichGit = require('./which.js')
const makeOpts = require('./opts.js')

module.exports = (gitArgs, opts = {}) => {
const whichGit = require('./which.js')
const gitPath = whichGit(opts)

if (gitPath instanceof Error) {
Expand Down

0 comments on commit c398872

Please sign in to comment.