onilabs / stratifiedjs

Oni StratifiedJS (previously Apollo)
http://onilabs.com/stratifiedjs
Other
231 stars 22 forks source link

Support distinction between run and require()d scripts #12

Closed timbertson closed 11 years ago

timbertson commented 12 years ago

We should do the same as node, in order to determine whether a script is run or required:

if (require.main === module) { ... }

and maybe also

if (!module.parent) { ... }

The first seems to be more official: http://nodejs.org/docs/v0.4.8/api/modules.html#accessing_the_main_module

http://stackoverflow.com/questions/4981891/node-js-equivalent-of-pythons-if-name-main