Skip to content

Commit c398872

Browse files
authored
fix: lazy load of which module (#176)
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.
1 parent 46192f5 commit c398872

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/spawn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ const spawn = require('@npmcli/promise-spawn')
22
const promiseRetry = require('promise-retry')
33
const log = require('proc-log')
44
const makeError = require('./make-error.js')
5-
const whichGit = require('./which.js')
65
const makeOpts = require('./opts.js')
76

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

1111
if (gitPath instanceof Error) {

0 commit comments

Comments
 (0)