split up types.ensureBlock into types.toBlock
This commit is contained in:
@@ -48,15 +48,27 @@ exports.isReferenced = function (node, parent) {
|
||||
};
|
||||
|
||||
exports.ensureBlock = function (node) {
|
||||
var block = node.body;
|
||||
if (block.type === "BlockStatement") return;
|
||||
node[key] = exports.toBlock(node.body, node);
|
||||
};
|
||||
|
||||
if (!_.isArray(block)) {
|
||||
if (!n.Statement.check(block)) block = b.returnStatement(block);
|
||||
block = [block];
|
||||
exports.toBlock = function (node, parent) {
|
||||
if (node.type === "BlockStatement") {
|
||||
return node;
|
||||
}
|
||||
|
||||
node.body = b.blockStatement(block);
|
||||
if (!_.isArray(node)) {
|
||||
if (!n.Statement.check(node)) {
|
||||
if (exports.isFunction(parent)) {
|
||||
node = b.returnStatement(node);
|
||||
} else {
|
||||
node = b.expressionStatement(node);
|
||||
}
|
||||
}
|
||||
|
||||
node = [node];
|
||||
}
|
||||
|
||||
return b.blockStatement(node);
|
||||
};
|
||||
|
||||
exports.getSpecifierName = function (specifier) {
|
||||
|
||||
Reference in New Issue
Block a user