1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4  value: true
5});
6exports.createRunOncePlugin = createRunOncePlugin;
7exports.withRunOnce = void 0;
8function _history() {
9  const data = require("../utils/history");
10  _history = function () {
11    return data;
12  };
13  return data;
14}
15/**
16 * Prevents the same plugin from being run twice.
17 * Used for migrating from unversioned expo config plugins to versioned plugins.
18 *
19 * @param config
20 * @param name
21 */
22const withRunOnce = (config, {
23  plugin,
24  name,
25  version
26}) => {
27  // Detect if a plugin has already been run on this config.
28  if ((0, _history().getHistoryItem)(config, name)) {
29    return config;
30  }
31
32  // Push the history item so duplicates cannot be run.
33  config = (0, _history().addHistoryItem)(config, {
34    name,
35    version
36  });
37  return plugin(config);
38};
39
40/**
41 * Helper method for creating mods from existing config functions.
42 *
43 * @param action
44 */
45exports.withRunOnce = withRunOnce;
46function createRunOncePlugin(plugin, name, version) {
47  return (config, props) => {
48    return withRunOnce(config, {
49      plugin: config => plugin(config, props),
50      name,
51      version
52    });
53  };
54}
55//# sourceMappingURL=withRunOnce.js.map