( tree = [], depth = 0, directoryPrefix = '∟ ', parent )
| 199 | * Given a dependency tree, do a pretty console log of the graph |
| 200 | */ |
| 201 | export function drawDependencyTree( |
| 202 | tree = [], |
| 203 | depth = 0, |
| 204 | directoryPrefix = '∟ ', |
| 205 | parent |
| 206 | ) { |
| 207 | for (const [i, branch] of tree.entries()) { |
| 208 | const title = branch[0] |
| 209 | const deps = branch[1] |
| 210 | const directoryIndent = `${' '.repeat(depth)}${ |
| 211 | depth > 0 ? directoryPrefix : '' |
| 212 | }${'— '.repeat(Math.min(1, depth))}` |
| 213 | if (depth === 0) { |
| 214 | console.log( |
| 215 | `${i + 1}) ${directoryIndent}${title} ` + |
| 216 | chalk.dim(`(${getPackageVersion(title)})`) |
| 217 | ) |
| 218 | } else { |
| 219 | msg.info( |
| 220 | ` ${directoryIndent}${title} ` + |
| 221 | chalk.dim(`(${getDependencyVersion(parent, title)})`) |
| 222 | ) |
| 223 | } |
| 224 | |
| 225 | if (deps) { |
| 226 | for (const dep of deps) { |
| 227 | drawDependencyTree([dep], depth + 1, directoryPrefix, title) |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * Given a package name, return relevant build files from the file system |
no test coverage detected