nyno-file-write

nyno-file-write — Write data to a file in a workflow


Description

- step: nyno-file-write
    args: ['${OUTPUT_FILE_PATH}', '${prev}']

The nyno-file-write step writes content from a variable or the output of a previous step to a specified file.

If the file does not exist, it will be created. If the file already exists, its contents are overwritten.

For generating unique file names, you can use nyno-uuidv4 or nyno-uuidv7 in your workflow.

Usage in a workflow YAML:

workflow:
  - step: nyno-file-write
    args: ['${OUTPUT_FILE_PATH}', '${prev}']

Parameters

Parameter Type Description
filePath string Path to the file where the data will be written. Can be an absolute or relative path.
content string or object The content to write. Typically the output of a previous step (${prev}), or any stringifiable variable. If it's an object, it will be JSON encoded.

Return Values

This step returns 0 on success and by default uses ${prev} to store an object like: { "file": "/app/output/x.txt", "bytes_written": 400 }


Behavior


Examples

Example #1 — Basic usage

workflow:
  - step: nyno-file-write
    args: ['/tmp/output.txt', '${prev}']

This writes the output of the previous workflow step into /tmp/output.txt.

Example #2 — Automatically generating filename using uuidv4

workflow:
  - step: nyno-uuidv4
  context:
    set_context: id_v4
  - step: nyno-file-write
    args: ['/app/output/${id_v4}.txt','generated file']

This writes 'generated file' into a file like /app/output/99a98c99-a69c-4356-90be-50e61f7c7dad.txt.


See Also