exemethod
require('exemethod')(); // => npm | script | globalcli | localcli | required | browserify | browser
It will tell your code how it was executed.
Usage
// [myscript.js] { return method; } var exemethod = ; var method = ; console;
will result in:
npm run myscript
=> npm- (assumes myscript.js is executed in a [package.json].script)
./myscript.js
=> script- (assumes
chmod +x myscript.js
)
- (assumes
npm install myscript -g
+myscript
=> globalcli- (assumes [package.json].bin field)
node usemyscript.js
=> required- (assumes something like
require('./myscript.js')
in "usemyscript.js")
- (assumes something like
node ./myscript.js
=> localclibrowserify myscript.js > b.js
=> browserify<script src='b.js'></script>
=> browser- (assumes you load "b.js" in an html page (e.g. via script tag))