|
'use strict' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var augmenters = [ |
|
[ |
|
'persistentOutputFlag', function(nodeInfo) { |
|
nodeInfo.persistentOutput = false |
|
} |
|
], [ |
|
'sourceDirectories', function(nodeInfo) { |
|
nodeInfo.nodeType = 'transform' |
|
} |
|
], [ |
|
'needsCacheFlag', function(nodeInfo) { |
|
if (nodeInfo.nodeType === 'transform') { |
|
nodeInfo.needsCache = true |
|
} |
|
} |
|
], [ |
|
'volatileFlag', function(nodeInfo) { |
|
if (nodeInfo.nodeType === 'transform') { |
|
nodeInfo.volatile = false |
|
} |
|
} |
|
], [ |
|
'trackInputChangesFlag', function(nodeInfo) { |
|
if (nodeInfo.nodeType === 'transform') { |
|
nodeInfo.trackInputChanges = false |
|
} |
|
} |
|
], [ |
|
'fsFacadeFlag', function (nodeInfo) { |
|
if (nodeInfo.nodeType === 'transform') { |
|
nodeInfo.fsFacade = false |
|
} |
|
} |
|
] |
|
] |
|
|
|
var features = {} |
|
for (var i = 0; i < augmenters.length; i++) { |
|
features[augmenters[i][0]] = true |
|
} |
|
exports.features = features |
|
|
|
|
|
exports.getNodeInfo = getNodeInfo |
|
function getNodeInfo(node) { |
|
|
|
if (node == null || !node.__broccoliGetInfo__) { |
|
if (typeof node === 'string') { |
|
throw new InvalidNodeError('"' + node + '": String nodes are not supported. Use the WatchedDir class provided by the broccoli-source package instead.') |
|
} else if (node != null && (typeof node.read === 'function' || typeof node.rebuild === 'function')) { |
|
var legacyNodeDescription = node.description || |
|
node.constructor && node.constructor.name || |
|
('' + node) |
|
throw new InvalidNodeError( |
|
legacyNodeDescription + |
|
': The .read/.rebuild API is no longer supported as of Broccoli 1.0. ' + |
|
'Plugins must now derive from broccoli-plugin. ' + |
|
'https://github.com/broccolijs/broccoli/blob/master/docs/broccoli-1-0-plugin-api.md') |
|
} else { |
|
throw new InvalidNodeError(node + ' is not a Broccoli node') |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var originalNodeInfo = node.__broccoliGetInfo__(features) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var nodeInfo = { |
|
|
|
|
|
get instantiationStack() { |
|
return originalNodeInfo.instantiationStack; |
|
} |
|
}; |
|
for (var key in originalNodeInfo) { |
|
if (key === 'instantiationStack') { |
|
continue; |
|
} |
|
|
|
nodeInfo[key] = originalNodeInfo[key] |
|
} |
|
|
|
|
|
for (var i = 0; i < augmenters.length; i++) { |
|
var feature = augmenters[i][0] |
|
if (!node.__broccoliFeatures__[feature]) { |
|
break |
|
} |
|
} |
|
|
|
|
|
for (; i < augmenters.length; i++) { |
|
var fn = augmenters[i][1] |
|
fn(nodeInfo) |
|
} |
|
|
|
|
|
|
|
|
|
if (nodeInfo.nodeType !== 'transform' && nodeInfo.nodeType !== 'source') { |
|
throw new InvalidNodeError('Unexpected nodeType: ' + nodeInfo.nodeType) |
|
} |
|
|
|
return nodeInfo |
|
} |
|
|
|
|
|
exports.InvalidNodeError = InvalidNodeError |
|
InvalidNodeError.prototype = Object.create(Error.prototype) |
|
InvalidNodeError.prototype.constructor = InvalidNodeError |
|
function InvalidNodeError(message) { |
|
|
|
|
|
var temp = Error.apply(this, arguments) |
|
|
|
temp.name = this.name = this.constructor.name |
|
this.stack = temp.stack |
|
this.message = temp.message |
|
} |
|
|