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

"SyntaxError: Unexpected token in JSON at position 0" when running CLI on MacOS #582

Closed
gino-m opened this issue Feb 22, 2024 · 2 comments
Closed
Labels

Comments

@gino-m
Copy link

gino-m commented Feb 22, 2024

This occurs when running using paths to process multiple files:

npx json2ts --no-declareExternallyReferenced --cwd=schemas/ -i schemas/ -o dist/generated

The offending file is the OS-specific:

"schemas/.DS_Store"

This file should be ignored. Since I wasn't able to get $refs to work correctly with nested folders, I flattened the schema dirs . As such this workaround works:

npx json2ts --no-declareExternallyReferenced --cwd=schemas/ -i 'schemas/*.schema.json' -o dist/generated
@bcherny
Copy link
Owner

bcherny commented Mar 2, 2024

This is working as expected. We could filter for JSON and Yaml files explicitly, but this may break consumers that use other file extensions.

PRs are welcome if you'd like to update the last example in the CLI docs to make this more apparent: https://github.com/bcherny/json-schema-to-typescript?tab=readme-ov-file#cli

@bcherny bcherny closed this as completed Mar 2, 2024
@bcherny bcherny added the wontfix label Mar 2, 2024
@gino-m
Copy link
Author

gino-m commented Mar 2, 2024

This is working as expected. We could filter for JSON and Yaml files explicitly, but this may break consumers that use other file extensions.

Thanks for the reply. On Linux and Linux-like OSes, .* indicates a hidden file. Is it expected that json2ts CLI would pick up hidden files as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants