also transforming of File asts

This commit is contained in:
Sebastian McKenzie
2015-08-12 02:57:36 +01:00
parent f923b2f5a4
commit 39fbd550c4

View File

@@ -7,9 +7,13 @@ import * as t from "babel-types";
*/
export default function (ast, comments, tokens) {
if (ast && ast.type === "Program") {
return t.file(ast, comments || [], tokens || []);
} else {
throw new Error("Not a valid ast?");
if (ast) {
if (ast.type === "Program") {
return t.file(ast, comments || [], tokens || []);
} else if (ast.type === "File") {
return ast;
}
}
throw new Error("Not a valid ast?");
}