matt-ball / postman-local

A client to facilitate local development of scripts for Postman.
Apache License 2.0
70 stars 6 forks source link

postman env error when no environments have been defined #26

Closed rucharnaud closed 4 years ago

rucharnaud commented 4 years ago

When running postman env against a postman account in which no environments have been defined, postman fails with the following error :

(node:2179) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined at createChoices (/Users/myself/Workspace/postman-cli-sandbox/node_modules/@matt.ball/postman-cli/src/lib/create-choices.js:2:14) at Command.env (/Users/myself/Workspace/postman-cli-sandbox/node_modules/@matt.ball/postman-cli/src/env.js:12:30) at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:2179) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:2179) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

It would be nice to catch this edge case, log a warning and exit gracefully.

postman-cli version : 0.0.26 node version : v12.16.1

matt-ball commented 4 years ago

Thanks for reporting again @rucharnaud - should be good in 0.0.27.