Skip to content

Commit

Permalink
refactor(core): restrict normalize to 1 object
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Jun 16, 2024
1 parent c0cbad7 commit 53bf297
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
16 changes: 7 additions & 9 deletions packages/core/lib/actions/fs/copy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions packages/core/lib/plugins/conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
21 changes: 13 additions & 8 deletions packages/core/lib/plugins/conditions/execute.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import session from '@nikitajs/core/session';
import { is_object_literal } from 'mixme';

const handlers = {
if_execute: async function(action) {
Expand All @@ -8,17 +9,19 @@ 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;
}
} catch (error) {
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
};
Expand All @@ -39,17 +42,19 @@ 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;
}
} catch (error) {
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
};
Expand Down

0 comments on commit 53bf297

Please sign in to comment.