app-root-path
Advanced tools
| declare namespace appRootPath { | ||
| export function resolve(pathToModule: string): string | ||
| export function require(pathToModule: string): ReturnType<NodeRequire> | ||
| export function toString(): string | ||
| export function setPath(explicitlySetPath: string): void | ||
| export const path: string | ||
| } | ||
| export = appRootPath |
+9
-2
@@ -110,4 +110,11 @@ 'use strict'; | ||
| // resort to require.main.filename (See http://nodejs.org/api/modules.html) | ||
| if (alternateMethod || null == appRootPath) { | ||
| appRootPath = path.dirname(requireFunction.main.filename); | ||
| if ((alternateMethod || null == appRootPath)) { | ||
| if (requireFunction.main) { | ||
| appRootPath = path.dirname(requireFunction.main.filename); | ||
| } else { | ||
| // This is the case when app-root-path is bundle'd to a commonjs2 format and is being called from an esm file. | ||
| // In those cases require.main is undefined (See https://nodejs.org/api/modules.html#accessing-the-main-module) | ||
| // At that point we can only get the root from looking at the callee | ||
| appRootPath = path.dirname(process.argv[1]); | ||
| } | ||
| } | ||
@@ -114,0 +121,0 @@ |
+1
-1
| { | ||
| "name": "app-root-path", | ||
| "version": "3.0.0", | ||
| "version": "3.1.0", | ||
| "description": "Determine an app's root path from anywhere inside the app", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+4
-0
@@ -93,2 +93,6 @@ # App Root Path Module | ||
| ### 3.1.0 | ||
| - Added TypeScript types | ||
| - Added fallback for when `require.main` is missing (ESM imports) | ||
| ### 3.0.0 | ||
@@ -95,0 +99,0 @@ - Improved Yarn Plug'n'Play support |
Sorry, the diff of this file is not supported yet
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
154
10.79%160
2.56%14962
-26.29%10
11.11%