Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-o/--output flag outputs an empty file #276

Open
bramdevries opened this Issue Jan 29, 2019 · 8 comments

Comments

Projects
None yet
6 participants
@bramdevries
Copy link

bramdevries commented Jan 29, 2019

Detailed description

Recently upgraded to speccy@0.9 and noticed a bug where speccy resolve api.yml -o output.yml would create an empty file instead of writing the contents.

Did not have any issues with this on speccy@0.8

Context

We have a setup where we use both JSON schemas and OpenAPI 3 specifications and need to use resolve to build a "correct" specification.

Possible implementation

The bug was introduced in f2f6936#diff-4955107868977657681b5dd27b54457aR32, by adding the return resolve outside of the fs.writeFile callback the process does not write any content to the file.

Your environment

I tested this both using the NPM module and the docker image on speccy@0.9. Was also able to reproduce this on the latest master with node speccy.js resolve examples/petstore.yaml -o petstore.yaml

  • Node Version: 8.12.0
  • Operating system and version: MacOS 10.14.2
  • Docker Version: 18.09.0
@pderaaij

This comment has been minimized.

Copy link
Contributor

pderaaij commented Jan 29, 2019

Thanks for catching this. I'll add test cases for mentioned issues in the upcoming days.

@bramdevries

This comment has been minimized.

Copy link
Author

bramdevries commented Jan 29, 2019

I fixed the issue and added an integration test in #277

@dlouzan

This comment has been minimized.

Copy link
Contributor

dlouzan commented Jan 30, 2019

Just a note: my pending MR #270 also solves this issue in a more general way (there's no need to return from a promise, only resolve/reject, and having a single branch exit for each condition makes the code more readable). There were other issues with that part of the code also affecting the stdin support.

The tests added in #277 are very nice though :-)

@dlouzan

This comment has been minimized.

Copy link
Contributor

dlouzan commented Jan 30, 2019

In fact this is clearly a bug, if an error occurs writing the file, it will reject() IFF the verbose flag is active:

if (err && verbose) {
  console.error('Failed to write file: ' + err.message);
  return reject();
}
@mdi

This comment has been minimized.

Copy link

mdi commented Mar 8, 2019

I'm also running into this issue. Any update on it?

@dlouzan

This comment has been minimized.

Copy link
Contributor

dlouzan commented Mar 9, 2019

@mdi The PR #270 merged yesterday should solve this. Please check the latest master.

@prsbisht98

This comment has been minimized.

Copy link

prsbisht98 commented Mar 19, 2019

Is it fixed for speccy@0.9?

@djtarazona

This comment has been minimized.

Copy link
Collaborator

djtarazona commented Mar 20, 2019

This is available in master. We'll be cutting a release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.