Skip to content

Commit

Permalink
fix(core): match against module instead of namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Mar 12, 2021
1 parent 15059f4 commit 554884c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
3 changes: 1 addition & 2 deletions packages/core/lib/plugins/execute.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 11 additions & 17 deletions packages/core/lib/plugins/ssh.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/core/src/metadata/tmpdir.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports =
handler: (action) ->
{config, metadata, tools} = action
throw utils.error 'METADATA_TMPDIR_INVALID', [
'the "tmpdir" metadata value must be a boolean or a string,'
"got #{typeof metadata.tmpdir}"
'the "tmpdir" metadata value must be a boolean, a function or a string,'
"got #{JSON.stringify metadata.tmpdir}"
] unless typeof metadata.tmpdir in ['boolean', 'function', 'string', 'undefined']
return unless metadata.tmpdir
# SSH connection extraction
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/plugins/execute.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ module.exports =
]
hooks:
'nikita:action':
# after: '@nikitajs/core/src/plugins/tools_find'
handler: ({config, metadata, tools: {find, walk}}) ->
return unless metadata.namespace.join('.') is 'execute'
return unless metadata.module is '@nikitajs/core/src/actions/execute'
config.arch_chroot ?= await find ({metadata: {arch_chroot}}) -> arch_chroot
config.arch_chroot_rootdir ?= await find ({metadata: {arch_chroot_rootdir}}) -> arch_chroot_rootdir
config.bash ?= await find ({metadata: {bash}}) -> bash
Expand Down
22 changes: 11 additions & 11 deletions packages/core/src/plugins/ssh.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ module.exports =
'@nikitajs/core/src/plugins/tools_find'
]
hooks:
'nikita:normalize': (action, handler) ->
# Dont interfere with ssh actions
return handler if action.metadata.namespace[0] is 'ssh'
if action.hasOwnProperty 'ssh'
ssh = action.ssh
delete action.ssh
->
action = await handler.call null, ...arguments
action.ssh = ssh
action
# 'nikita:normalize': (action, handler) ->
# # Dont interfere with ssh actions
# return handler if action.metadata.namespace[0] is 'ssh'
# if action.hasOwnProperty 'ssh'
# ssh = action.ssh
# delete action.ssh
# ->
# action = await handler.call null, ...arguments
# action.ssh = ssh
# action
'nikita:action': (action) ->
# Is there a connection to open
if action.ssh and not utils.ssh.is action.ssh
Expand Down Expand Up @@ -59,7 +59,7 @@ module.exports =
]
# Find SSH open in previous siblings
for sibling in action.siblings
continue unless sibling.metadata.namespace.join('.') is 'ssh.open'
continue unless sibling.metadata.module is '@nikitajs/core/src/actions/ssh/open'
if sibling.output.ssh
ssh = sibling.output.ssh
break
Expand Down

0 comments on commit 554884c

Please sign in to comment.