Non-existing input file doesn't result in error
ulugbekna opened this issue · comments
It would be nice if ts2ocaml
warned or errored if given a non-existing file as input.
Currently ts2ocaml jsoo --create-minimal-stdlib --preset=minimal --safe-arity=full --simplify=all not-existing-file.d.ts
returns 0, generates the minimal stdlib, but does nothing else to warn the user.
Making sure the input files have correct extension .d.ts
may also be nice.
Not reproducing in my environment:
Error: ENOENT: no such file or directory, open 'not-existing-file.d.ts'
at Object.openSync (fs.js:498:3)
at Object.readFileSync (fs.js:394:35)
at /usr/local/lib/node_modules/@ocsigen/ts2ocaml/dist/ts2ocaml.js:2:381811
at /usr/local/lib/node_modules/@ocsigen/ts2ocaml/dist/ts2ocaml.js:2:33961
at xn.next (/usr/local/lib/node_modules/@ocsigen/ts2ocaml/dist/ts2ocaml.js:2:31572)
at xn.System.Collections.IEnumerator.MoveNext (/usr/local/lib/node_modules/@ocsigen/ts2ocaml/dist/ts2ocaml.js:2:31140)
at /usr/local/lib/node_modules/@ocsigen/ts2ocaml/dist/ts2ocaml.js:2:33955
at xn.next (/usr/local/lib/node_modules/@ocsigen/ts2ocaml/dist/ts2ocaml.js:2:31572)
at xn.System.Collections.IEnumerator.MoveNext (/usr/local/lib/node_modules/@ocsigen/ts2ocaml/dist/ts2ocaml.js:2:31140)
at en (/usr/local/lib/node_modules/@ocsigen/ts2ocaml/dist/ts2ocaml.js:2:27744) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: 'not-existing-file.d.ts'
}
It should fail on fs.readFileSync()
.
I will add another layer of existence & file extension check regardless.
Maybe it depends on the version of Node. Can you let me know which version of Node you are using?
I think I figured out why: TypeScript compiler API doesn't throw an exception if the file actually doesn't exist. I need to add a manual check here.