aboutsummaryrefslogtreecommitdiff
path: root/node_modules/require-main-filename/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/require-main-filename/index.js')
-rw-r--r--node_modules/require-main-filename/index.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/node_modules/require-main-filename/index.js b/node_modules/require-main-filename/index.js
new file mode 100644
index 0000000..dca7f0c
--- /dev/null
+++ b/node_modules/require-main-filename/index.js
@@ -0,0 +1,18 @@
+module.exports = function (_require) {
+ _require = _require || require
+ var main = _require.main
+ if (main && isIISNode(main)) return handleIISNode(main)
+ else return main ? main.filename : process.cwd()
+}
+
+function isIISNode (main) {
+ return /\\iisnode\\/.test(main.filename)
+}
+
+function handleIISNode (main) {
+ if (!main.children.length) {
+ return main.filename
+ } else {
+ return main.children[0].filename
+ }
+}