Remove unneeded helper file.
This commit is contained in:
parent
7b5d4fe069
commit
f3f907bdb3
@ -1,23 +0,0 @@
|
||||
import * as t from "babel-types";
|
||||
|
||||
/**
|
||||
* Normalize an AST.
|
||||
*
|
||||
* - Wrap `Program` node with a `File` node.
|
||||
*/
|
||||
|
||||
export default function (
|
||||
ast: Object,
|
||||
comments?: Array<Object>,
|
||||
tokens?: Array<Object>,
|
||||
) {
|
||||
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?");
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
/* global BabelFileResult, BabelFileMetadata */
|
||||
import fs from "fs";
|
||||
|
||||
import normalizeAst from "../helpers/normalize-ast";
|
||||
import * as t from "babel-types";
|
||||
import File from "./file";
|
||||
import OptionManager from "../config/option-manager";
|
||||
|
||||
@ -30,7 +30,11 @@ export function transformFromAst(ast: Object, code: string, opts: Object): Babel
|
||||
opts = new OptionManager().init(opts);
|
||||
if (opts === null) return null;
|
||||
|
||||
ast = normalizeAst(ast);
|
||||
if (ast && ast.type === "Program") {
|
||||
return t.file(ast, [], []);
|
||||
} else if (!ast || ast.type !== "File") {
|
||||
throw new Error("Not a valid ast?");
|
||||
}
|
||||
|
||||
const file = new File(opts);
|
||||
return file.wrap(code, function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user