javanile / yamlinc

Compose multiple YAML files into one with $include tag. Split Swagger/OpenAPI into multiple YAML files.
MIT License
114 stars 24 forks source link

[BUG] Yamlinc must fail when $include path was't found #9

Open svmk opened 6 years ago

svmk commented 6 years ago

Version: v0.0.65 Steps to reproduce:

  1. Create file main.yml
    some_key: "some_value"
    some_data:
    $include: included_file_that_does_not_exists.yml
  2. Run yamlinc main.yml && cat main.inc.yml Output:
    
    ## --------------------
    ## DON'T EDIT THIS FILE
    ## --------------------
    ## Engine: yamlinc@0.1.1
    ## Source: main.yml

some_key: some_value some_data: {}



Expected result:
Yamlinc must exit with status 1 and print error message: "Included file included_file_that_does_not_exists.yml was't found" 
justinnichols commented 6 years ago

v0.1.1 also exhibits this behavior. I agree that this should notify the user, but there may be use cases where not finding a file is the behavior the user would want. I suggest that it should warn the user that a file (or files) weren't found for inclusion, instead of erroring.

The other issue I see is that it's putting {} in its place (indicating an empty map). Should this be an empty string (assuming it won't error and only warn)?

Thoughts?

francescobianco commented 5 years ago

Hi @svmk @justinnichols there is a news about this in version 0.1.5 we can use '--strict' option in commad-line

The strict mode stop if 'Problem' occur during runtime (e.g. Syntax error or missing files) To respect your chain use this:

$ yamlinc --strict main.yml && cat main.inc.yml

On the next day I work to found a solution for {}