summaryrefslogtreecommitdiff
path: root/node_modules/tapable/lib/SyncBailHook.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-08-30 17:21:18 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-08-30 17:21:18 +0800
commitefbc2ffe6a1ee5ec38a4396305561d6515d0943e (patch)
tree2b4c94f18f2c792dfda813050755d5c0273fae22 /node_modules/tapable/lib/SyncBailHook.js
parent43acceb75957c880a5ba5a31aae221394a36d5f6 (diff)
node fixes, updates
Diffstat (limited to 'node_modules/tapable/lib/SyncBailHook.js')
-rw-r--r--node_modules/tapable/lib/SyncBailHook.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/node_modules/tapable/lib/SyncBailHook.js b/node_modules/tapable/lib/SyncBailHook.js
new file mode 100644
index 00000000..bdd5b453
--- /dev/null
+++ b/node_modules/tapable/lib/SyncBailHook.js
@@ -0,0 +1,51 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const Hook = require("./Hook");
+const HookCodeFactory = require("./HookCodeFactory");
+
+class SyncBailHookCodeFactory extends HookCodeFactory {
+ content({ onError, onResult, resultReturns, onDone, rethrowIfPossible }) {
+ return this.callTapsSeries({
+ onError: (i, err) => onError(err),
+ onResult: (i, result, next) =>
+ `if(${result} !== undefined) {\n${onResult(
+ result
+ )};\n} else {\n${next()}}\n`,
+ resultReturns,
+ onDone,
+ rethrowIfPossible
+ });
+ }
+}
+
+const factory = new SyncBailHookCodeFactory();
+
+const TAP_ASYNC = () => {
+ throw new Error("tapAsync is not supported on a SyncBailHook");
+};
+
+const TAP_PROMISE = () => {
+ throw new Error("tapPromise is not supported on a SyncBailHook");
+};
+
+const COMPILE = function(options) {
+ factory.setup(this, options);
+ return factory.create(options);
+};
+
+function SyncBailHook(args = [], name = undefined) {
+ const hook = new Hook(args, name);
+ hook.constructor = SyncBailHook;
+ hook.tapAsync = TAP_ASYNC;
+ hook.tapPromise = TAP_PROMISE;
+ hook.compile = COMPILE;
+ return hook;
+}
+
+SyncBailHook.prototype = null;
+
+module.exports = SyncBailHook;