matt-ball / postman-local

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

Error when adding scripts to a request previously bootstrapped with none. #37

Closed kevinswiber closed 4 years ago

kevinswiber commented 4 years ago

After adding a prerequest.js to a request directory locally, I received an error on postman sync.

➜ postman sync
(node:32815) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'findIndex' of undefined
    at mapFileToItem (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/sync.js:23:31)
    at recurseCollectionForItems (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/lib/recurse-collection.js:34:20)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async recurseCollectionForItems (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/lib/recurse-collection.js:40:7)
    at async recurseCollection (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/lib/recurse-collection.js:13:5)
    at async Command.sync (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/sync.js:9:22)

The error is here: https://github.com/matt-ball/postman-cli/blob/cdaa51c05ffde6d68e8465df2d6e30d6e4b0b7ab/src/sync.js#L23

In this case, req.event does not exist and needs to be created.