Skip to content

Commit

Permalink
Fix eslint errors
Browse files Browse the repository at this point in the history
This includes fixes to line-endings, brace-style, and max-len.
  • Loading branch information
medallyon committed Nov 26, 2021
1 parent f5c74ab commit 72278e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
21 changes: 10 additions & 11 deletions src/commands/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {colorizeDiff} from 'npm-check-updates/lib/version-util';

import catchAsyncError from '../catchAsyncError';
import {makeFilterFunction} from '../filterUtils';
import {DEPS_GROUPS, loadGlobalPackages, loadPackageJson, setModuleVersion, getModuleInfo, getModuleHomepage} from '../packageUtils';
import {DEPS_GROUPS, loadGlobalPackages, loadPackageJson, setModuleVersion,
getModuleInfo, getModuleHomepage} from '../packageUtils';
import {fetchRemoteDb, findModuleChangelogUrl} from '../changelogUtils';
import {createSimpleTable} from '../cliTable';
import {strong, success, attention} from '../cliStyles';
Expand Down Expand Up @@ -56,12 +57,9 @@ export const handler = catchAsyncError(async opts => {
if (_.every(DEPS_GROUPS, ({name}) => !opts[name])) {
_.each(DEPS_GROUPS, ({name}) => (opts[name] = true));
opts.global = false;
}

// Make global flag mutually exclusive with other flags
else if (opts.global) {
for (let i = 0; i < DEPS_GROUPS.length; i++)
_.each(DEPS_GROUPS, ({name}) => { opts[name] = false });
} else if (opts.global) {
// Make global flag mutually exclusive with other flags
for (let i = 0; i < DEPS_GROUPS.length; i++) {_.each(DEPS_GROUPS, ({name}) => { opts[name] = false })}
opts.global = true;
}

Expand All @@ -78,7 +76,8 @@ export const handler = catchAsyncError(async opts => {
const filteredWith = filter ? `filtered with ${strong(filter)} ` : '';

console.log(
`Checking for outdated ${depsGroupsToCheckStr}dependencies ${filteredWith}${opts.global ? '' : (`for "${strong(packageFile)}"`)}...`
`Checking for outdated ${depsGroupsToCheckStr}dependencies ${filteredWith}${opts.global ? '' :
(`for "${strong(packageFile)}"`)}...`
);

const ncuDepGroups = DEPS_GROUPS
Expand Down Expand Up @@ -160,7 +159,8 @@ export const handler = catchAsyncError(async opts => {

const answer = await askUser({
type: 'list',
message: `${changelogUrl === undefined ? 'U' : 'So, u'}pdate "${name}" ${opts.global ? 'globally' : 'in package.json'} from ${from} to ${colorizeDiff(from, to)}?`,
message: `${changelogUrl === undefined ? 'U' : 'So, u'}pdate "${name}" ${opts.global ? 'globally' :
'in package.json'} from ${from} to ${colorizeDiff(from, to)}?`,
choices: _.compact([
{name: 'Yes', value: true},
{name: 'No', value: false},
Expand Down Expand Up @@ -258,8 +258,7 @@ export const handler = catchAsyncError(async opts => {
{type: 'confirm', message: 'Update global modules?', default: true}
);

if (!shouldUpdateGlobalPackages)
return;
if (!shouldUpdateGlobalPackages) {return}

console.log(`Automatically upgrading ${updatedModules.length} module${updatedModules.length !== 1 ? 's' : ''}...`);
return shell.exec(`npm install --global ${updatedModules.map(({name, to}) => `${name}@${to}`).join(' ')}`);
Expand Down
8 changes: 3 additions & 5 deletions src/packageUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@ const getNpmConfig = _.memoize(() => {

export function loadGlobalPackages() {
const res = shell.exec('npm ls -g --depth 0 --json', {silent: true});
if (res.code !== 0)
throw new Error(`Could not determine global packages: ${res.stderr}`);
if (res.code !== 0) {throw new Error(`Could not determine global packages: ${res.stderr}`)}

try {
const {dependencies} = JSON.parse(res);
const content = {dependencies};

for (const [ pkg, {version} ] of Object.entries(dependencies))
content.dependencies[pkg] = version;
for (const [pkg, {version}] of Object.entries(dependencies)) {content.dependencies[pkg] = version}

return {content}
return {content};
} catch (err) {
console.error(`Error parsing global packages: ${err.message}`);
process.exit(1);
Expand Down

0 comments on commit 72278e7

Please sign in to comment.