Skip to content

Commit 1c8d41d

Browse files
committed
deps: @npmcli/[email protected]
1 parent 3101a40 commit 1c8d41d

File tree

5 files changed

+60
-11
lines changed

5 files changed

+60
-11
lines changed

DEPENDENCIES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ graph LR;
199199
npmcli-docs-->npmcli-template-oss["@npmcli/template-oss"];
200200
npmcli-docs-->semver;
201201
npmcli-fs-->semver;
202+
npmcli-git-->ini;
202203
npmcli-git-->npm-pick-manifest;
203204
npmcli-git-->npmcli-promise-spawn["@npmcli/promise-spawn"];
204205
npmcli-git-->proc-log;
@@ -643,6 +644,7 @@ graph LR;
643644
npmcli-docs-->unified;
644645
npmcli-docs-->yaml;
645646
npmcli-fs-->semver;
647+
npmcli-git-->ini;
646648
npmcli-git-->lru-cache;
647649
npmcli-git-->npm-pick-manifest;
648650
npmcli-git-->npmcli-promise-spawn["@npmcli/promise-spawn"];
@@ -801,4 +803,4 @@ packages higher up the chain.
801803
- @npmcli/git, make-fetch-happen
802804
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, promzard
803805
- @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, normalize-package-data, npm-packlist, bin-links, nopt, parse-conflict-json, @npmcli/mock-globals, read
804-
- @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, @npmcli/redact, @npmcli/agent, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, proggy, minify-registry-metadata, ini, mute-stream, npm-audit-report, npm-user-validate
806+
- @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, ini, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, @npmcli/redact, @npmcli/agent, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, proggy, minify-registry-metadata, mute-stream, npm-audit-report, npm-user-validate

node_modules/@npmcli/git/lib/opts.js

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,57 @@
1+
const fs = require('node:fs')
2+
const os = require('node:os')
3+
const path = require('node:path')
4+
const ini = require('ini')
5+
6+
const gitConfigPath = path.join(os.homedir(), '.gitconfig')
7+
8+
let cachedConfig = null
9+
10+
// Function to load and cache the git config
11+
const loadGitConfig = () => {
12+
if (cachedConfig === null) {
13+
try {
14+
cachedConfig = {}
15+
if (fs.existsSync(gitConfigPath)) {
16+
const configContent = fs.readFileSync(gitConfigPath, 'utf-8')
17+
cachedConfig = ini.parse(configContent)
18+
}
19+
} catch (error) {
20+
cachedConfig = {}
21+
}
22+
}
23+
return cachedConfig
24+
}
25+
26+
const checkGitConfigs = () => {
27+
const config = loadGitConfig()
28+
return {
29+
sshCommandSetInConfig: config?.core?.sshCommand !== undefined,
30+
askPassSetInConfig: config?.core?.askpass !== undefined,
31+
}
32+
}
33+
34+
const sshCommandSetInEnv = process.env.GIT_SSH_COMMAND !== undefined
35+
const askPassSetInEnv = process.env.GIT_ASKPASS !== undefined
36+
const { sshCommandSetInConfig, askPassSetInConfig } = checkGitConfigs()
37+
138
// Values we want to set if they're not already defined by the end user
239
// This defaults to accepting new ssh host key fingerprints
3-
const gitEnv = {
4-
GIT_ASKPASS: 'echo',
5-
GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new',
40+
const finalGitEnv = {
41+
...(askPassSetInEnv || askPassSetInConfig ? {} : {
42+
GIT_ASKPASS: 'echo',
43+
}),
44+
...(sshCommandSetInEnv || sshCommandSetInConfig ? {} : {
45+
GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new',
46+
}),
647
}
48+
749
module.exports = (opts = {}) => ({
850
stdioString: true,
951
...opts,
1052
shell: false,
11-
env: opts.env || { ...gitEnv, ...process.env },
53+
env: opts.env || { ...finalGitEnv, ...process.env },
1254
})
55+
56+
// Export the loadGitConfig function for testing
57+
module.exports.loadGitConfig = loadGitConfig

node_modules/@npmcli/git/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@npmcli/git",
3-
"version": "5.0.7",
3+
"version": "5.0.8",
44
"main": "lib/index.js",
55
"files": [
66
"bin/",
@@ -38,6 +38,7 @@
3838
},
3939
"dependencies": {
4040
"@npmcli/promise-spawn": "^7.0.0",
41+
"ini": "^4.1.3",
4142
"lru-cache": "^10.0.1",
4243
"npm-pick-manifest": "^9.0.0",
4344
"proc-log": "^4.0.0",

package-lock.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"devDependencies": {
163163
"@npmcli/docs": "^1.0.0",
164164
"@npmcli/eslint-config": "^4.0.2",
165-
"@npmcli/git": "^5.0.7",
165+
"@npmcli/git": "^5.0.8",
166166
"@npmcli/mock-globals": "^1.0.0",
167167
"@npmcli/mock-registry": "^1.0.0",
168168
"@npmcli/template-oss": "4.22.0",
@@ -1626,13 +1626,14 @@
16261626
}
16271627
},
16281628
"node_modules/@npmcli/git": {
1629-
"version": "5.0.7",
1630-
"resolved": "https://registry.npmjs.org/@npmcli/git/-/git-5.0.7.tgz",
1631-
"integrity": "sha512-WaOVvto604d5IpdCRV2KjQu8PzkfE96d50CQGKgywXh2GxXmDeUO5EWcBC4V57uFyrNqx83+MewuJh3WTR3xPA==",
1629+
"version": "5.0.8",
1630+
"resolved": "https://registry.npmjs.org/@npmcli/git/-/git-5.0.8.tgz",
1631+
"integrity": "sha512-liASfw5cqhjNW9UFd+ruwwdEf/lbOAQjLL2XY2dFW/bkJheXDYZgOyul/4gVvEV4BWkTXjYGmDqMw9uegdbJNQ==",
16321632
"inBundle": true,
16331633
"license": "ISC",
16341634
"dependencies": {
16351635
"@npmcli/promise-spawn": "^7.0.0",
1636+
"ini": "^4.1.3",
16361637
"lru-cache": "^10.0.1",
16371638
"npm-pick-manifest": "^9.0.0",
16381639
"proc-log": "^4.0.0",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
"devDependencies": {
194194
"@npmcli/docs": "^1.0.0",
195195
"@npmcli/eslint-config": "^4.0.2",
196-
"@npmcli/git": "^5.0.7",
196+
"@npmcli/git": "^5.0.8",
197197
"@npmcli/mock-globals": "^1.0.0",
198198
"@npmcli/mock-registry": "^1.0.0",
199199
"@npmcli/template-oss": "4.22.0",

0 commit comments

Comments
 (0)