diff --git a/packages/core/lib/actions/fs/copy/index.js b/packages/core/lib/actions/fs/copy/index.js index 9cc40dbe7..b94ebb662 100644 --- a/packages/core/lib/actions/fs/copy/index.js +++ b/packages/core/lib/actions/fs/copy/index.js @@ -52,15 +52,13 @@ export default { })() // Create target parent directory if target does not exists and if the "parent" // config is set to "true" (default) or as an object. - await this.fs.mkdir( - { - $if: !!config.parent, - $unless: target_stats, - $shy: true, - target: path.dirname(config.target), - }, - config.parent - ); + await this.fs.mkdir({ + $if: !!config.parent, + $unless: target_stats, + $shy: true, + target: path.dirname(config.target), + ...config.parent + }); // Stop here if source is a directory. We traverse all its children // Recursively, calling either `fs.mkdir` or `fs.copy`. // Like with the Unix `cp` command, ending slash matters if the target directory diff --git a/packages/core/lib/plugins/conditions.js b/packages/core/lib/plugins/conditions.js index 6a8e6f45e..6672beaf2 100644 --- a/packages/core/lib/plugins/conditions.js +++ b/packages/core/lib/plugins/conditions.js @@ -9,8 +9,9 @@ const handlers = { $bastard: true, $handler: condition, $parent: action, - $raw_output: true - }, action.config); + $raw_output: true, + ...action.config + }); } const run = (function() { switch (typeof condition) { @@ -48,8 +49,9 @@ const handlers = { $bastard: true, $handler: condition, $parent: action, - $raw_output: true - }, action.config); + $raw_output: true, + ...action.config + }); } const run = (function() { switch (typeof condition) { diff --git a/packages/core/lib/plugins/conditions/execute.js b/packages/core/lib/plugins/conditions/execute.js index c02fb90b6..f74a4f0ac 100644 --- a/packages/core/lib/plugins/conditions/execute.js +++ b/packages/core/lib/plugins/conditions/execute.js @@ -1,5 +1,6 @@ import session from '@nikitajs/core/session'; +import { is_object_literal } from 'mixme'; const handlers = { if_execute: async function(action) { @@ -8,8 +9,9 @@ const handlers = { const {$status} = await session({ $bastard: true, $namespace: ['execute'], - $parent: action - }, condition); + $parent: action, + ...(is_object_literal(condition) ? condition : {}), + }, is_object_literal(condition) ? null : condition); if (!$status) { return false; } @@ -17,8 +19,9 @@ const handlers = { const {code} = await session({ $bastard: true, $namespace: ['execute'], - $parent: action - }, condition, function({config}) { + $parent: action, + ...(is_object_literal(condition) ? condition : {}), + }, is_object_literal(condition) ? null : condition, function({config}) { return { code: config.code }; @@ -39,8 +42,9 @@ const handlers = { const {$status} = await session({ $bastard: true, $namespace: ['execute'], - $parent: action - }, condition); + $parent: action, + ...(is_object_literal(condition) ? condition : {}), + }, is_object_literal(condition) ? null : condition); if ($status) { return false; } @@ -48,8 +52,9 @@ const handlers = { const {code} = await session({ $bastard: true, $namespace: ['execute'], - $parent: action - }, condition, function({config}) { + $parent: action, + ...(is_object_literal(condition) ? condition : {}), + }, is_object_literal(condition) ? null : condition, function({config}) { return { code: config.code };