"SyntaxError: Unexpected token in JSON at position 0" when running CLI on MacOS
Closed this issue · 2 comments
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 $ref
s 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
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
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?