Closed timbertson closed 11 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
We should do the same as node, in order to determine whether a script is run or required:
and maybe also
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