How to run the new `mongosh` with a JS file?

These do not work:

mongosh --shell consoletable.js
Current sessionID:  77dbd754f7b36b026be1b82f
Connecting to:      mongodb://consoletable.js:27017/test
mongosh consoletable.js --shell
Current sessionID:  77dc0556b638ce307878c5bc
Connecting to:      mongodb://consoletable.js:27017/test
mongosh consoletable.js
Current sessionID:  77df76ef26ae494504e8c4ec
Connecting to:      mongodb://consoletable.js:27017/test
2 Likes

That is currently not supported.

What you can try is to start mongosh and then from inside the shell do

> .load ./consoletable.js
2 Likes