Projekt

Obecné

Profil

Stáhnout (2.14 KB) Statistiky
| Větev: | Revize:
1
"use strict";
2

    
3
exports.__esModule = true;
4

    
5
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
6

    
7
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
8

    
9
var _normalizeAst = require("../helpers/normalize-ast");
10

    
11
var _normalizeAst2 = _interopRequireDefault(_normalizeAst);
12

    
13
var _plugin = require("./plugin");
14

    
15
var _plugin2 = _interopRequireDefault(_plugin);
16

    
17
var _file = require("./file");
18

    
19
var _file2 = _interopRequireDefault(_file);
20

    
21
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22

    
23
var Pipeline = function () {
24
  function Pipeline() {
25
    (0, _classCallCheck3.default)(this, Pipeline);
26
  }
27

    
28
  Pipeline.prototype.lint = function lint(code) {
29
    var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30

    
31
    opts.code = false;
32
    opts.mode = "lint";
33
    return this.transform(code, opts);
34
  };
35

    
36
  Pipeline.prototype.pretransform = function pretransform(code, opts) {
37
    var file = new _file2.default(opts, this);
38
    return file.wrap(code, function () {
39
      file.addCode(code);
40
      file.parseCode(code);
41
      return file;
42
    });
43
  };
44

    
45
  Pipeline.prototype.transform = function transform(code, opts) {
46
    var file = new _file2.default(opts, this);
47
    return file.wrap(code, function () {
48
      file.addCode(code);
49
      file.parseCode(code);
50
      return file.transform();
51
    });
52
  };
53

    
54
  Pipeline.prototype.analyse = function analyse(code) {
55
    var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
56
    var visitor = arguments[2];
57

    
58
    opts.code = false;
59
    if (visitor) {
60
      opts.plugins = opts.plugins || [];
61
      opts.plugins.push(new _plugin2.default({ visitor: visitor }));
62
    }
63
    return this.transform(code, opts).metadata;
64
  };
65

    
66
  Pipeline.prototype.transformFromAst = function transformFromAst(ast, code, opts) {
67
    ast = (0, _normalizeAst2.default)(ast);
68

    
69
    var file = new _file2.default(opts, this);
70
    return file.wrap(code, function () {
71
      file.addCode(code);
72
      file.addAst(ast);
73
      return file.transform();
74
    });
75
  };
76

    
77
  return Pipeline;
78
}();
79

    
80
exports.default = Pipeline;
81
module.exports = exports["default"];
(1-1/3)