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

feat: create dir for output file #1241

Open
cuhland opened this issue Dec 6, 2024 · 4 comments · May be fixed by #1242
Open

feat: create dir for output file #1241

cuhland opened this issue Dec 6, 2024 · 4 comments · May be fixed by #1242
Assignees
Labels
breaking-change breacking change. causes a new major version. enhancement New feature or request
Milestone

Comments

@cuhland
Copy link
Contributor

cuhland commented Dec 6, 2024

Describe the bug

When the output-file contains a path, then the generation fails.
I want to place the result of the sbom not in the root directory, but in a dedicated build folder for further processing in the pipeline.

To Reproduce

The following call

cyclonedx-npm --output-file build/reports/sbom.json

will cause an ERROR and no sbom is generated.

Error: ENOENT: no such file or directory, open '<path>/build/reports/sbom.json'

Process finished with exit code 254

Expected behavior

The folders are generated if the --output-file argument contains a path.

Environment

  • @cyclonedx/cyclonedx-npm version: 1.19.3
  • NPM version: 10.9.0
  • Node version: v23.1.0
  • OS: mac
@cuhland cuhland added the bug Something isn't working label Dec 6, 2024
@cuhland cuhland linked a pull request Dec 9, 2024 that will close this issue
3 tasks
@jkowalleck jkowalleck added enhancement New feature or request and removed bug Something isn't working labels Dec 9, 2024
@jkowalleck
Copy link
Member

jkowalleck commented Dec 9, 2024

this is not a bug, but intended behavior.
if the directory of the target file does not exist, the creation of the target file fails.

Expected behavior
The folders are generated if the --output-file argument contains a path.

could you elaborate why this "feature" would be needed?
why don't you create the folder yourself, if it does not exist? don't you have control over your own file system?

@jkowalleck jkowalleck changed the title [BUG] ERROR when --output-file contains a path feat: create dir for output file Dec 9, 2024
@jkowalleck
Copy link
Member

the following worked for me:

mkdir -p dist/foo/bar
cyclonedx-npm --output-file dist/foo/bar/bom.cdx.json

@cuhland
Copy link
Contributor Author

cuhland commented Dec 9, 2024

this is not a bug, but intended behavior. if the directory of the target file does not exist, the creation of the target file fails.

I agree that is not a bug, but an enhancement.

could you elaborate why this "feature" would be needed? why don't you create the folder yourself, if it does not exist? don't you have control over your own file system?

For sure, I can create a folder myself. But it is easier for the caller, if the library supports the creation of a directory if needed.

@jkowalleck
Copy link
Member

jkowalleck commented Dec 9, 2024

But it is easier for the caller [...]

I understand.

This sounds like a nice-to-have feature, but in fact, I'd consider it a breaking change:
current behavior is to fail if target folder does not exist, yet.
This comment is a remark, not a blocker.

@jkowalleck jkowalleck added the breaking-change breacking change. causes a new major version. label Dec 9, 2024
@jkowalleck jkowalleck added this to the v2.0.0 milestone Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change breacking change. causes a new major version. enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants