index.js 427 B

123456789101112131415161718
  1. module.exports = function (_require) {
  2. _require = _require || require
  3. var main = _require.main
  4. if (main && isIISNode(main)) return handleIISNode(main)
  5. else return main ? main.filename : process.cwd()
  6. }
  7. function isIISNode (main) {
  8. return /\\iisnode\\/.test(main.filename)
  9. }
  10. function handleIISNode (main) {
  11. if (!main.children.length) {
  12. return main.filename
  13. } else {
  14. return main.children[0].filename
  15. }
  16. }