1const Arborist = require('../') 2 3const log = require('./lib/logging.js') 4 5module.exports = (options, time) => { 6 const query = options._.shift() 7 const a = new Arborist(options) 8 return a 9 .loadVirtual() 10 .then(tree => { 11 // only load the actual tree if the virtual one doesn't have modern metadata 12 if (!tree.meta || !(tree.meta.originalLockfileVersion >= 2)) { 13 log.error('old metadata, load actual') 14 throw 'load actual' 15 } else { 16 log.error('meta ok, return virtual tree') 17 return tree 18 } 19 }) 20 .catch(() => a.loadActual()) 21 .then(time) 22 .then(({ timing, result: tree }) => { 23 if (!query) { 24 for (const node of tree.inventory.values()) { 25 if (node.package.funding) { 26 log.info(node.name, node.location, node.package.funding) 27 } 28 } 29 } else { 30 for (const node of tree.inventory.query('name', query)) { 31 if (node.package.funding) { 32 log.info(node.name, node.location, node.package.funding) 33 } 34 } 35 } 36 return `read ${tree.inventory.size} deps in ${timing.ms}` 37 }) 38} 39