Last active
August 9, 2021 21:58
-
-
Save krisselden/01b9c1559a1adc80c0096e2661809541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-env node */ | |
const Project = require('ember-cli/lib/models/project'); | |
const CLI = require('ember-cli/lib/cli/cli'); | |
const UI = require('console-ui'); | |
const ui = new UI(); | |
const cli = new CLI({ ui }); | |
const project = Project.closestSync(__dirname, ui, cli); | |
const tree = require(`${project.root}/ember-cli-build`)({ project }); | |
module.exports = tree; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printTree(require('./load_broccoli_tree')); | |
/** | |
* @param {import('broccoli-node-api').InputNode} node | |
*/ | |
function printTree(node, seen = new Set(), depth = 0) { | |
if (typeof node === 'string') { | |
console.log(' '.repeat(depth), node); | |
return; | |
} | |
// eslint-disable-next-line no-underscore-dangle | |
const nodeInfo = node.__broccoliGetInfo__(); | |
if (seen.has(node)) { | |
console.log(' '.repeat(depth), 'REF >', nodeLabel(nodeInfo)); | |
return; | |
} | |
seen.add(node); | |
if (nodeInfo.nodeType === 'transform') { | |
const { inputNodes } = nodeInfo; | |
if (inputNodes.length > 0) { | |
console.log(' '.repeat(depth), 'START', inputNodes.length, nodeLabel(nodeInfo)); | |
// flatten consecutive merge trees into one | |
for (const child of inputNodes) { | |
printTree(child, seen, depth + 1); | |
} | |
console.log(' '.repeat(depth), 'END', nodeLabel(nodeInfo)); | |
} else { | |
console.log(' '.repeat(depth), nodeLabel(nodeInfo)); | |
} | |
} else { | |
console.log(' '.repeat(depth), nodeLabel(nodeInfo)); | |
} | |
} | |
/** | |
* @param {import('broccoli-node-api').SourceNodeInfo} node | |
*/ | |
function nodeLabel(node) { | |
const name = node.nodeType === 'source' ? node.sourceDirectory : node.name; | |
const { annotation } = node; | |
if (annotation) { | |
return `${name} ${annotation}`; | |
} | |
return name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment