Remove babel.analyse and surrounding helpers.
This commit is contained in:
@@ -31,7 +31,6 @@ export function Plugin(alias) {
|
||||
|
||||
export {
|
||||
transform,
|
||||
analyse,
|
||||
transformFromAst,
|
||||
transformFile,
|
||||
transformFileSync,
|
||||
|
||||
@@ -67,7 +67,6 @@ export default class File {
|
||||
}
|
||||
|
||||
this.metadata = {
|
||||
marked: [],
|
||||
modules: {
|
||||
imports: [],
|
||||
exports: {
|
||||
|
||||
@@ -1,23 +1,10 @@
|
||||
/* global BabelFileResult, BabelFileMetadata */
|
||||
/* global BabelFileResult */
|
||||
import fs from "fs";
|
||||
|
||||
import * as t from "babel-types";
|
||||
import File from "./file";
|
||||
import loadConfig from "../config";
|
||||
|
||||
export function analyse(
|
||||
code: string,
|
||||
opts: Object = {},
|
||||
visitor?: Object,
|
||||
): ?BabelFileMetadata {
|
||||
opts.code = false;
|
||||
if (visitor) {
|
||||
opts.plugins = opts.plugins || [];
|
||||
opts.plugins.push({ visitor });
|
||||
}
|
||||
return transform(code, opts).metadata;
|
||||
}
|
||||
|
||||
export function transform(code: string, opts?: Object): BabelFileResult {
|
||||
const config = loadConfig(opts);
|
||||
if (config === null) return null;
|
||||
|
||||
@@ -103,38 +103,6 @@ describe("parser and generator options", function() {
|
||||
});
|
||||
|
||||
describe("api", function() {
|
||||
it("analyze", function() {
|
||||
assert.equal(babel.analyse("foobar;").marked.length, 0);
|
||||
|
||||
assert.equal(
|
||||
babel.analyse("foobar;", {
|
||||
plugins: [
|
||||
new Plugin({
|
||||
visitor: {
|
||||
Program: function(path) {
|
||||
path.mark("category", "foobar");
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
}).marked[0].message,
|
||||
"foobar",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
babel.analyse(
|
||||
"foobar;",
|
||||
{},
|
||||
{
|
||||
Program: function(path) {
|
||||
path.mark("category", "foobar");
|
||||
},
|
||||
},
|
||||
).marked[0].message,
|
||||
"foobar",
|
||||
);
|
||||
});
|
||||
|
||||
it("exposes the resolvePlugin method", function() {
|
||||
assert.throws(
|
||||
() => babel.resolvePlugin("nonexistent-plugin"),
|
||||
|
||||
@@ -126,14 +126,6 @@ export default class NodePath {
|
||||
traverse(this.node, visitor, this.scope, state, this);
|
||||
}
|
||||
|
||||
mark(type: string, message: string) {
|
||||
this.hub.file.metadata.marked.push({
|
||||
type,
|
||||
message,
|
||||
loc: this.node.loc,
|
||||
});
|
||||
}
|
||||
|
||||
set(key: string, node: Object) {
|
||||
t.validate(this.node, key, node);
|
||||
this.node[key] = node;
|
||||
|
||||
Reference in New Issue
Block a user