Skip to content

Commit

Permalink
Fix variable names based on code review
Browse files Browse the repository at this point in the history
  • Loading branch information
cb1kenobi committed May 9, 2024
1 parent 370a8ca commit 459e7f7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
25 changes: 14 additions & 11 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,21 @@ export class CLI {
* @access private
*/
applyArgv(cmd) {
if (Array.isArray(cmd?.options)) {
const argv = this.argv;
const cargv = cmd.opts();
this.debugLogger.trace(`Copying ${cmd.options.length} options... (${cmd.name()})`);
for (const o of cmd.options) {
let name = o.name();
if (o.negate) {
name = name.replace(/^no-/, '');
}
this.debugLogger.trace(` Setting ${name} = ${cargv[o.attributeName()]} (prev: ${argv[name]})`);
argv[name] = cargv[o.attributeName()];
if (!Array.isArray(cmd?.options)) {
return;
}

const argv = this.argv;
const cargv = cmd.opts();
this.debugLogger.trace(`Copying ${cmd.options.length} options... (${cmd.name()})`);

for (const opt of cmd.options) {
let name = opt.name();
if (opt.negate) {
name = name.replace(/^no-/, '');
}
this.debugLogger.trace(` Setting ${name} = ${cargv[opt.attributeName()]} (prev: ${argv[name]})`);
argv[name] = cargv[opt.attributeName()];
}
}

Expand Down
16 changes: 10 additions & 6 deletions src/util/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ async function osInfo() {
let name = process.platform;
let version = '?';
let m;
let n;
let _;
const { $ } = await import('execa');

if (name === 'darwin') {
Expand All @@ -111,18 +109,24 @@ async function osInfo() {
version = m[1];
}
} else if (name === 'linux') {
name = 'GNU/Linux';
if (existsSync('/etc/lsb-release')) {
const s = await readFile('/etc/lsb-release', 'utf-8');
if (m = s.match(/DISTRIB_DESCRIPTION=(.+)/i)) {
n = m[1].replaceAll('"', '');
name = m[1].replaceAll('"', '');
}
if (m = s.match(/DISTRIB_RELEASE=(.+)/i)) {
n = m[1].replaceAll('"', '');
name = m[1].replaceAll('"', '');
}
} else if (existsSync('/etc/system-release')) {
[name, _, version] = (await readFile('/etc/system-release', 'utf-8')).split(' ');
const parts = (await readFile('/etc/system-release', 'utf-8')).split(' ');
if (parts.length) {
name = parts[0];
}
if (parts.length > 2) {
version = parts[2];
}
}
name = n || 'GNU/Linux';
} else {
const { stdout } = await $`wmic os get Caption,Version`;
[name, version] = stdout.split('\n')[1].split(/ {2,}/);
Expand Down

0 comments on commit 459e7f7

Please sign in to comment.