microsoft / dts-gen

dts-gen creates starter TypeScript definition files for any module or library.
MIT License
2.43k stars 102 forks source link

Fix crash when types directory does not exist #62

Closed leonard-thieu closed 6 years ago

leonard-thieu commented 7 years ago

This PR fixes dts-gen crashing when the types directory does not exist.


dts-gen crashes when used with the --dt argument and the types subdirectory does not exist. This can happen if you run dts-gen --dt anywhere besides the root of the DefinitelyTyped repo.

"C:\Program Files (x86)\nodejs\node.exe" --inspect-brk=55971 S:\Projects\_GitHub\dts-gen\bin\lib\run.js --dt --name angular-tooltips --template module --overwrite
Unexpected crash! Please log a bug with the commandline you specified.
S:\Projects\_GitHub\dts-gen\bin\lib\run.js:130
        throw e;
        ^

Error: ENOENT: no such file or directory, mkdir 'S:\Projects\_GitHub\dts-gen\types\angular-tooltips'
    at Object.fs.mkdirSync (fs.js:895:18)
    at Object.writeDefinitelyTypedPackage [as default] (S:\Projects\_GitHub\dts-gen\bin\lib\definitely-typed.js:24:14)
    at Object.<anonymous> (S:\Projects\_GitHub\dts-gen\bin\lib\run.js:92:35)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)
msftclas commented 7 years ago

@leonard-thieu, Thanks for having already signed the Contribution License Agreement. Your agreement has not been validated yet. We will now review your pull request. Thanks, Microsoft Pull Request Bot