ssh-config 4.4.2 → 4.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +4 -2
  2. package/src/ssh-config.js +10 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ssh-config",
3
3
  "description": "SSH config parser and stringifier",
4
- "version": "4.4.2",
4
+ "version": "4.4.3",
5
5
  "author": "Chen Yangjian (https://www.cyj.me)",
6
6
  "repository": {
7
7
  "type": "git",
@@ -16,12 +16,14 @@
16
16
  "devDependencies": {
17
17
  "@types/mocha": "^9.1.0",
18
18
  "@types/node": "^17.0.45",
19
+ "@types/sinon": "^17.0.3",
19
20
  "@typescript-eslint/eslint-plugin": "^5.48.0",
20
21
  "@typescript-eslint/parser": "^5.48.0",
21
22
  "eslint": "^8.31.0",
22
23
  "heredoc": "^1.3.1",
23
24
  "mocha": "^8.2.1",
24
25
  "nyc": "^15.1.0",
26
+ "sinon": "^17.0.1",
25
27
  "typescript": "^4.6.3"
26
28
  },
27
29
  "scripts": {
@@ -33,7 +35,7 @@
33
35
  "test:coverage": "nyc mocha --exit --recursive && nyc report --reporter=lcov"
34
36
  },
35
37
  "engine": {
36
- "node": ">= 10.0.0"
38
+ "node": ">= 14.0.0"
37
39
  },
38
40
  "license": "MIT"
39
41
  }
package/src/ssh-config.js CHANGED
@@ -91,13 +91,21 @@ class SSHConfig extends Array {
91
91
  compute(opts) {
92
92
  if (typeof opts === 'string')
93
93
  opts = { Host: opts };
94
+ let userInfo;
95
+ try {
96
+ userInfo = os_1.default.userInfo();
97
+ }
98
+ catch (_a) {
99
+ // os.userInfo() throws a SystemError if a user has no username or homedir.
100
+ userInfo = { username: process.env.USER || process.env.USERNAME || '' };
101
+ }
94
102
  const context = {
95
103
  params: {
96
104
  Host: opts.Host,
97
105
  HostName: opts.Host,
98
106
  OriginalHost: opts.Host,
99
- User: os_1.default.userInfo().username,
100
- LocalUser: os_1.default.userInfo().username,
107
+ User: userInfo.username,
108
+ LocalUser: userInfo.username,
101
109
  },
102
110
  inFinalPass: false,
103
111
  doFinalPass: false,