const { exec } = require("child_process");

let ran = false;

/**
 * @typedef {Object} Options
 * @property {string} command - The command to run
 * @property {boolean=} once - Whether to run the script only once
 * @param options {Options}
 */
module.exports = function ShellOnBuildEndPlugin(options) {
  this.apply = compiler => {
    compiler.hooks.afterEmit.tap("AfterEmitPlugin", () => {
      if (!ran) {
        exec(options.command, (err, stdout, stderr) => {
          if (stdout) process.stdout.write(stdout);
          if (stderr) process.stderr.write(stderr);
        });

        if (options.once) {
          ran = true;
        }
      }
    });
  };
};

@@ -41,26 +41,8 @@
 );%0A%0A
-let ran = false;%0A%0A
 /**%0A
@@ -279,16 +279,37 @@
 ions) %7B%0A
+  this.run = false;%0A%0A
   this.a
@@ -400,16 +400,21 @@
    if (!
+this.
 ran) %7B%0A 
@@ -610,24 +610,24 @@
 ons.once) %7B%0A
-
           ra
@@ -624,16 +624,21 @@
         
+this.
 ran = tr

Fix shell-on-build-end-webpack plugin run flag being set globally