mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-30 16:14:06 +00:00
rm: ununsed fn
This commit is contained in:
@@ -286,69 +286,6 @@ const HOOK_EVENTS = Object.freeze({
|
||||
RUNNER_AFTER_COLLECTION_RUN: 'runner:afterCollectionRun'
|
||||
});
|
||||
|
||||
/**
|
||||
* Get or create HookManager for a specific level (collection, folder, or request)
|
||||
* @param {Map} hookManagersMap - Map storing HookManagers by key
|
||||
* @param {string} uid - Unique identifier (collectionUid, folderUid, or requestUid)
|
||||
* @param {string} hooksFile - Hooks file content for this level
|
||||
* @param {object} options - Options for hook registration
|
||||
* @param {object} options.request - Request object
|
||||
* @param {object} options.envVars - Environment variables
|
||||
* @param {object} options.runtimeVariables - Runtime variables
|
||||
* @param {string} options.collectionPath - Collection path
|
||||
* @param {function} options.onConsoleLog - Console log callback
|
||||
* @param {object} options.processEnvVars - Process environment variables
|
||||
* @param {object} options.scriptingConfig - Scripting configuration
|
||||
* @param {function} options.runRequestByItemPathname - Function to run requests
|
||||
* @param {string} options.collectionName - Collection name
|
||||
* @returns {Promise<HookManager>} HookManager instance for this level
|
||||
*/
|
||||
const getOrCreateHookManager = async (hookManagersMap, uid, hooksFile, options = {}) => {
|
||||
// Return existing HookManager if already created
|
||||
if (hookManagersMap.has(uid)) {
|
||||
return hookManagersMap.get(uid);
|
||||
}
|
||||
|
||||
// Create new HookManager and register hooks
|
||||
const hookManager = new HookManager();
|
||||
hookManagersMap.set(uid, hookManager);
|
||||
|
||||
if (hooksFile && hooksFile.trim()) {
|
||||
const hooksRuntime = new HooksRuntime({ runtime: options.scriptingConfig?.runtime });
|
||||
try {
|
||||
await hooksRuntime.runHooks({
|
||||
hooksFile: decomment(hooksFile),
|
||||
hookManager,
|
||||
request: options.request || {},
|
||||
envVariables: options.envVars || options.envVariables || {},
|
||||
runtimeVariables: options.runtimeVariables || {},
|
||||
collectionPath: options.collectionPath,
|
||||
onConsoleLog: options.onConsoleLog,
|
||||
processEnvVars: options.processEnvVars || {},
|
||||
scriptingConfig: options.scriptingConfig || {},
|
||||
runRequestByItemPathname: options.runRequestByItemPathname,
|
||||
collectionName: options.collectionName
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Error registering hooks for ${uid}:`, error);
|
||||
if (options.onConsoleLog) {
|
||||
options.onConsoleLog('error', [`Error registering hooks for ${uid}: ${error.message}`]);
|
||||
}
|
||||
// Notify frontend if notification parameters are provided (for collection runner)
|
||||
if (options.notifyScriptExecution && options.eventData) {
|
||||
options.notifyScriptExecution({
|
||||
channel: 'main:run-folder-event',
|
||||
basePayload: options.eventData,
|
||||
scriptType: 'hooks',
|
||||
error
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hookManager;
|
||||
};
|
||||
|
||||
const flattenItems = (items = []) => {
|
||||
const flattenedItems = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user