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