Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
bin: remove outdated ERESOLVE printing code
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Feb 12, 2021
1 parent f375873 commit 828990c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 53 deletions.
56 changes: 4 additions & 52 deletions bin/ideal.js
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
})
2 changes: 1 addition & 1 deletion bin/lib/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit 828990c

Please sign in to comment.