Skip to content

Commit 459e7f7

Browse files
committed
Fix variable names based on code review
1 parent 370a8ca commit 459e7f7

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

src/cli.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,18 +213,21 @@ export class CLI {
213213
* @access private
214214
*/
215215
applyArgv(cmd) {
216-
if (Array.isArray(cmd?.options)) {
217-
const argv = this.argv;
218-
const cargv = cmd.opts();
219-
this.debugLogger.trace(`Copying ${cmd.options.length} options... (${cmd.name()})`);
220-
for (const o of cmd.options) {
221-
let name = o.name();
222-
if (o.negate) {
223-
name = name.replace(/^no-/, '');
224-
}
225-
this.debugLogger.trace(` Setting ${name} = ${cargv[o.attributeName()]} (prev: ${argv[name]})`);
226-
argv[name] = cargv[o.attributeName()];
216+
if (!Array.isArray(cmd?.options)) {
217+
return;
218+
}
219+
220+
const argv = this.argv;
221+
const cargv = cmd.opts();
222+
this.debugLogger.trace(`Copying ${cmd.options.length} options... (${cmd.name()})`);
223+
224+
for (const opt of cmd.options) {
225+
let name = opt.name();
226+
if (opt.negate) {
227+
name = name.replace(/^no-/, '');
227228
}
229+
this.debugLogger.trace(` Setting ${name} = ${cargv[opt.attributeName()]} (prev: ${argv[name]})`);
230+
argv[name] = cargv[opt.attributeName()];
228231
}
229232
}
230233

src/util/detect.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ async function osInfo() {
9898
let name = process.platform;
9999
let version = '?';
100100
let m;
101-
let n;
102-
let _;
103101
const { $ } = await import('execa');
104102

105103
if (name === 'darwin') {
@@ -111,18 +109,24 @@ async function osInfo() {
111109
version = m[1];
112110
}
113111
} else if (name === 'linux') {
112+
name = 'GNU/Linux';
114113
if (existsSync('/etc/lsb-release')) {
115114
const s = await readFile('/etc/lsb-release', 'utf-8');
116115
if (m = s.match(/DISTRIB_DESCRIPTION=(.+)/i)) {
117-
n = m[1].replaceAll('"', '');
116+
name = m[1].replaceAll('"', '');
118117
}
119118
if (m = s.match(/DISTRIB_RELEASE=(.+)/i)) {
120-
n = m[1].replaceAll('"', '');
119+
name = m[1].replaceAll('"', '');
121120
}
122121
} else if (existsSync('/etc/system-release')) {
123-
[name, _, version] = (await readFile('/etc/system-release', 'utf-8')).split(' ');
122+
const parts = (await readFile('/etc/system-release', 'utf-8')).split(' ');
123+
if (parts.length) {
124+
name = parts[0];
125+
}
126+
if (parts.length > 2) {
127+
version = parts[2];
128+
}
124129
}
125-
name = n || 'GNU/Linux';
126130
} else {
127131
const { stdout } = await $`wmic os get Caption,Version`;
128132
[name, version] = stdout.split('\n')[1].split(/ {2,}/);

0 commit comments

Comments
 (0)