{"size": 2053, "ext": "js", "max_stars_repo_path": "node_modules/babel-plugin-debug-macros/dist/index.js", "max_stars_repo_name": "rahmakevo/Ember-question-answer", "max_stars_repo_stars_event_min_datetime": "2019-02-11T12:13:59.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-01T17:32:19.000Z", "max_issues_repo_path": "node_modules/babel-plugin-debug-macros/dist/index.js", "max_issues_repo_name": "rahmakevo/Ember-question-answer", "max_issues_repo_issues_event_min_datetime": "2019-01-18T09:41:04.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T07:54:10.000Z", "max_forks_repo_path": "node_modules/babel-plugin-debug-macros/dist/index.js", "max_forks_repo_name": "rahmakevo/Ember-question-answer", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 23, "max_forks_count": null, "avg_line_length": 26.6623376623, "max_line_length": 95, "alphanum_fraction": 0.5986361422}
'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _macros = require('./lib/utils/macros');

var _macros2 = _interopRequireDefault(_macros);

var _fs = require('fs');

var _path = require('path');

var _normalizeOptions = require('./lib/utils/normalize-options');

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

function macros(babel) {
  var t = babel.types;

  var macroBuilder = void 0;
  var options = void 0;

  return {
    name: "babel-feature-flags-and-debug-macros",
    visitor: {

      Program: {
        enter(path, state) {
          var _this = this;

          options = (0, _normalizeOptions.normalizeOptions)(state.opts);
          this.macroBuilder = new _macros2.default(t, options);

          var body = path.get('body');

          body.forEach(function (item) {
            if (item.isImportDeclaration()) {
              var importPath = item.node.source.value;

              var _options = options,
                  featureSources = _options.featureSources,
                  debugToolsImport = _options.debugTools.debugToolsImport,
                  _options$envFlags = _options.envFlags,
                  envFlagsImport = _options$envFlags.envFlagsImport,
                  flags = _options$envFlags.flags;


              var isFeaturesImport = featureSources.indexOf(importPath) > -1;

              if (debugToolsImport && debugToolsImport === importPath) {
                _this.macroBuilder.collectDebugToolsSpecifiers(item.get('specifiers'));
              }if (envFlagsImport && envFlagsImport === importPath) {
                _this.macroBuilder.collectEnvFlagSpecifiers(item.get('specifiers'));
              }
            }
          });
        },

        exit(path) {
          this.macroBuilder.expand(path);
        }
      },

      ExpressionStatement(path) {
        this.macroBuilder.build(path);
      }
    }
  };
}

macros.baseDir = function () {
  return (0, _path.dirname)(__dirname);
};

exports.default = macros;