From 1e08b2c2f0392654030a09a06bb7ca35dfb0ed84 Mon Sep 17 00:00:00 2001 From: David Worms Date: Sat, 17 Feb 2024 18:55:52 +0100 Subject: [PATCH] refactor(core): simplify namespace definition --- packages/core/lib/plugins/args.js | 1 - packages/core/lib/session.js | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/core/lib/plugins/args.js b/packages/core/lib/plugins/args.js index 4d6670317..1116fd05b 100644 --- a/packages/core/lib/plugins/args.js +++ b/packages/core/lib/plugins/args.js @@ -19,7 +19,6 @@ export default { // If raw_input is activated, just pass arguments as is // Always one action since arguments are erased if (child?.metadata?.raw_input) { - action.args = args; action.metadata.raw_input = true; } action.args = args; diff --git a/packages/core/lib/session.js b/packages/core/lib/session.js index 65909273e..efca5640d 100644 --- a/packages/core/lib/session.js +++ b/packages/core/lib/session.js @@ -96,16 +96,13 @@ const session = function(args, options = {}) { return contextualize([ ...args, { - $namespace: namespace + $namespace: namespace || [] } ]); } }); action.parent = options.parent; action.plugins = plugins; - if (action.metadata.namespace == null) { - action.metadata.namespace = []; - } // Initialize the registry to manage action registration action.registry = registry.create({ plugins: action.plugins, @@ -141,12 +138,12 @@ const session = function(args, options = {}) { const result = new Promise(async function(resolve, reject) { try { // Hook intented to modify the current action being created - action = (await action.plugins.call({ - name: 'nikita:normalize', + action = await action.plugins.call({ + name: "nikita:normalize", args: action, hooks: action.hooks?.on_normalize || action.on_normalize, - handler: normalize - })); + handler: normalize, + }); } catch (error) { schedulers.out.end(error); return reject(error);