From 828990cbbe2e8e99f0f4d33f9c4fe88965306fb8 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 11 Feb 2021 14:29:38 -0800 Subject: [PATCH] bin: remove outdated ERESOLVE printing code --- bin/ideal.js | 56 ++++------------------------------------------ bin/lib/logging.js | 2 +- 2 files changed, 5 insertions(+), 53 deletions(-) diff --git a/bin/ideal.js b/bin/ideal.js index 18a5b9eb3..74d79ce0a 100644 --- a/bin/ideal.js +++ b/bin/ideal.js @@ -1,59 +1,11 @@ const Arborist = require('../') +const { inspect } = require('util') const options = require('./lib/options.js') const print = require('./lib/print-tree.js') require('./lib/logging.js') require('./lib/timers.js') -const c = require('chalk') - -const whichIsA = (name, dependents, indent = ' ') => { - if (!dependents || dependents.length === 0) - return '' - const str = `\nfor: ` + - dependents.map(dep => { - return dep.more ? `${dep.more} more (${dep.names.join(', ')})` - : `${dep.type} dependency ` + - `${c.bold(name)}@"${c.bold(dep.spec)}"` + `\nfrom:` + - (dep.from.location ? (dep.from.name - ? ` ${c.bold(dep.from.name)}@${c.bold(dep.from.version)} ` + - c.dim(`at ${dep.from.location}`) - : ' the root project') - : ` ${c.bold(dep.from.name)}@${c.bold(dep.from.version)}`) + - whichIsA(dep.from.name, dep.from.dependents, ' ') - }).join('\nand: ') - - return str.split(/\n/).join(`\n${indent}`) -} - -const explainEresolve = ({ dep, current, peerConflict, fixWithForce }) => { - return (!dep.whileInstalling ? '' : `While resolving: ` + - `${c.bold(dep.whileInstalling.name)}@${c.bold(dep.whileInstalling.version)}\n`) + - - `Found: ` + - `${c.bold(current.name)}@${c.bold(current.version)} ` + - c.dim(`at ${current.location}`) + - `${whichIsA(current.name, current.dependents)}` + - - `\n\nCould not add conflicting dependency: ` + - `${c.bold(dep.name)}@${c.bold(dep.version)} ` + - c.dim(`at ${dep.location}`) + - `${whichIsA(dep.name, dep.dependents)}\n` + - - (!peerConflict ? '' : - `\nConflicting peer dependency: ` + - `${c.bold(peerConflict.name)}@${c.bold(peerConflict.version)} ` + - c.dim(`at ${peerConflict.location}`) + - `${whichIsA(peerConflict.name, peerConflict.dependents)}\n` - ) + - - `\nFix the upstream dependency conflict, or -run this command with --legacy-peer-deps${ - fixWithForce ? ' or --force' : ''} -to accept an incorrect (and potentially broken) dependency resolution. -` -} - const start = process.hrtime() new Arborist(options).buildIdealTree(options).then(tree => { const end = process.hrtime(start) @@ -62,7 +14,7 @@ new Arborist(options).buildIdealTree(options).then(tree => { if (tree.meta && options.save) tree.meta.save() }).catch(er => { - console.error(er) - if (er.code === 'ERESOLVE') - console.error(explainEresolve(er)) + const opt = { depth: Infinity, color: true } + console.error(er.code === 'ERESOLVE' ? inspect(er, opt) : er) + process.exitCode = 1 }) diff --git a/bin/lib/logging.js b/bin/lib/logging.js index 57597b2e5..a7d20a1f5 100644 --- a/bin/lib/logging.js +++ b/bin/lib/logging.js @@ -26,7 +26,7 @@ if (loglevel !== 'silent') { return const pref = `${process.pid} ${level} ` if (level === 'warn' && args[0] === 'ERESOLVE') - args[2] = inspect(args[2], { depth: Infinity }) + args[2] = inspect(args[2], { depth: 10 }) const msg = pref + format(...args).trim().split('\n').join(`\n${pref}`) console.error(msg) })