Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Call node.__broccoliGetInfo__()
let nodeInfo;
try {
nodeInfo = broccoliNodeInfo.getNodeInfo(node);
} catch (e) {
if (!(e instanceof broccoliNodeInfo.InvalidNodeError)) throw e;
// We don't have the instantiation stack of an invalid node, so to aid
// debugging, we instead report its parent node
const messageSuffix =
_stack.length > 0
? '\nused as input node to ' +
_stack[_stack.length - 1].label +
_stack[_stack.length - 1].formatInstantiationStackForTerminal()
: '\nused as output node';
throw new broccoliNodeInfo.InvalidNodeError(e.message + messageSuffix);
}
// Compute label, like "Funnel (test suite)"
let label = nodeInfo.name;
const labelExtras = [];
if (nodeInfo.nodeType === 'source') labelExtras.push(nodeInfo.sourceDirectory);
if (nodeInfo.annotation != null) labelExtras.push(nodeInfo.annotation);
if (labelExtras.length > 0) label += ' (' + labelExtras.join('; ') + ')';
// We start constructing the nodeWrapper here because we'll need the partial
// nodeWrapper for the _stack. Later we'll add more properties.
const nodeWrapper: any =
nodeInfo.nodeType === 'transform' ? new TransformNodeWrapper() : new SourceNodeWrapper();
nodeWrapper.nodeInfo = nodeInfo;
nodeWrapper.originalNode = originalNode;
nodeWrapper.node = node;
makeNodeWrapper(node: Node, _stack: any = []) {
let wrapper = this._nodeWrappers.get(node);
if (wrapper !== undefined) {
return wrapper;
}
// Turn string nodes into WatchedDir nodes
const originalNode = node; // keep original (possibly string) node around for deduping
if (typeof node === 'string') {
node = new WatchedDir(node, { annotation: 'string node' });
}
// Call node.__broccoliGetInfo__()
let nodeInfo;
try {
nodeInfo = broccoliNodeInfo.getNodeInfo(node);
} catch (e) {
if (!(e instanceof broccoliNodeInfo.InvalidNodeError)) throw e;
// We don't have the instantiation stack of an invalid node, so to aid
// debugging, we instead report its parent node
const messageSuffix =
_stack.length > 0
? '\nused as input node to ' +
_stack[_stack.length - 1].label +
_stack[_stack.length - 1].formatInstantiationStackForTerminal()
: '\nused as output node';
throw new broccoliNodeInfo.InvalidNodeError(e.message + messageSuffix);
}
// Compute label, like "Funnel (test suite)"
let label = nodeInfo.name;
const labelExtras = [];
get features() {
return broccoliNodeInfo.features;
}
};