Skip to content

Commit

Permalink
feat(core): config enter in log.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Mar 9, 2021
1 parent 562299c commit bb9c496
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 60 deletions.
21 changes: 20 additions & 1 deletion packages/core/lib/actions/log/md.js

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

2 changes: 0 additions & 2 deletions packages/core/lib/plugins/args.js

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

6 changes: 0 additions & 6 deletions packages/core/lib/plugins/assertions.js

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

13 changes: 2 additions & 11 deletions packages/core/lib/plugins/assertions_exists.js

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

16 changes: 2 additions & 14 deletions packages/core/lib/plugins/conditions.js

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

6 changes: 0 additions & 6 deletions packages/core/lib/plugins/conditions_execute.js

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

6 changes: 0 additions & 6 deletions packages/core/lib/plugins/conditions_exists.js

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

14 changes: 2 additions & 12 deletions packages/core/lib/plugins/conditions_os.js

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

23 changes: 22 additions & 1 deletion packages/core/src/actions/log/md.coffee.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@

Write log to the host filesystem in Markdown.

## Example

```js
nikita(async function(){
await this.log.md({
basedir: './logs',
filename: 'nikita.log'
})
await this.call(({tools: {log}}) => {
log({message: 'hello'})
})
})
```

## Hook

on_action = ({config}) ->
Expand All @@ -22,6 +36,12 @@ Write log to the host filesystem in Markdown.
The characters used to join the hierarchy of headers to create a
markdown header.
"""
enter:
type: 'boolean'
default: true
description: '''
Enable or disable the entering messages.
'''
]
## Handler
Expand All @@ -31,7 +51,8 @@ Write log to the host filesystem in Markdown.
await @call $: log_fs, config, serializer:
'nikita:action:start': ({action}) ->
content = []
content.push "\nEntering #{action.metadata.module} (#{(action.metadata.position.map (index) -> index + 1).join '.'})\n" if action.metadata.module
if config.enter and action.metadata.module
content.push "\nEntering #{action.metadata.module} (#{(action.metadata.position.map (index) -> index + 1).join '.'})\n"
return content.join '' unless action.metadata.header
walk = (parent) ->
precious = parent.metadata.header
Expand Down
19 changes: 18 additions & 1 deletion packages/core/test/actions/log/md.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe 'actions.log.md', ->
target: "#{tmpdir}/localhost.log"
content: 'ok (1.INFO, written by nikita/test/log/md)'

describe 'header', ->
describe 'metadata `header`', ->

they 'honors header', ({ssh}) ->
nikita
Expand Down Expand Up @@ -163,3 +163,20 @@ describe 'actions.log.md', ->
echo 'this is a second line'
```
"""

describe 'config `enter`', ->

they 'disabled when false', ({ssh}) ->
nikita
$ssh: ssh
$tmpdir: true
, ({metadata: {tmpdir}}) ->
await @log.md basedir: tmpdir, enter: false
await @call (->)
await @call (->)
@fs.base.readFile
target: "#{tmpdir}/localhost.log"
encoding: 'ascii'
.should.be.resolvedWith
data: ''

0 comments on commit bb9c496

Please sign in to comment.