improve detection if called via command line or `require` as a module
Merge pull request #79 from mozilla/master

Improve detection if called directly or required as a module