dev-cli icon indicating copy to clipboard operation
dev-cli copied to clipboard

Undefined Property 'typescript' in dev-cli if devDependencies is missing

Open Warchant opened this issue 5 years ago • 0 comments

My project uses lerna. When I execute lerna link convert - it removes all devDependencies from my packages.

Then, if I run task oclif-dev readme, it fails with this error:

wrote manifest to /home/bogdan/tools/nodecore-js/packages/ncjs-cli/oclif.manifest.json
replacing <!-- usage --> in README.md
TypeError: Cannot read property 'typescript' of undefined
    at Readme.commandPath (~/tools/nodecore-js/packages/ncjs-cli/node_modules/@oclif/dev-cli/lib/commands/readme.js:189:42)
    at Readme.commandCode (~/tools/nodecore-js/packages/ncjs-cli/node_modules/@oclif/dev-cli/lib/commands/readme.js:137:32)
    at Readme.renderCommand (~/tools/nodecore-js/packages/ncjs-cli/node_modules/@oclif/dev-cli/lib/commands/readme.js:122:18)
    at ~/tools/nodecore-js/packages/ncjs-cli/node_modules/@oclif/dev-cli/lib/commands/readme.js:110:39
    at Array.map (<anonymous>)
    at Readme.commands (~/tools/nodecore-js/packages/ncjs-cli/node_modules/@oclif/dev-cli/lib/commands/readme.js:110:25)
    at Readme.run (~/tools/nodecore-js/packages/ncjs-cli/node_modules/@oclif/dev-cli/lib/commands/readme.js:36:123)
    at async Readme._run (~/tools/nodecore-js/packages/ncjs-cli/node_modules/@oclif/command/lib/command.js:42:20)
    at async Config.runCommand (~/tools/nodecore-js/packages/ncjs-cli/node_modules/@oclif/config/lib/config.js:172:9)
    at async Main.run (~/tools/nodecore-js/packages/ncjs-cli/node_modules/@oclif/command/lib/main.js:21:9)
lerna info lifecycle [email protected]~prepack: Failed to exec prepack script
lerna ERR! lifecycle "prepack" errored in "ncjs-cli", exiting 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is because here https://github.com/oclif/dev-cli/blob/master/src/commands/readme.ts#L197 and https://github.com/oclif/dev-cli/blob/master/src/commands/readme.ts#L208 no 'undefined' check.

Once I added empty devDependencies - command worked.

Maybe use elvis operator or add undefined guards?

Version: oclif/1.15.2 linux-x64 node-v13.12.0

Warchant avatar Apr 21 '20 10:04 Warchant