@@ -5064,6 +5064,20 @@ function extractAbiMethods(networkCache, methodNames) {
50645064}
50655065
50665066// packages/contracts/src/custom-network-signatures.ts
5067+ function getCurrentModulePath ( ) {
5068+ const moduleUrl = __import_meta__ ?. url ;
5069+ if ( typeof moduleUrl === "string" ) {
5070+ try {
5071+ return ( 0 , import_url . fileURLToPath ) ( moduleUrl ) ;
5072+ } catch ( error ) {
5073+ console . warn ( "Failed to resolve fileURLToPath from import.meta.url:" , error ) ;
5074+ }
5075+ }
5076+ if ( typeof __filename !== "undefined" ) {
5077+ return __filename ;
5078+ }
5079+ return void 0 ;
5080+ }
50675081function getBaseDirectory ( useScriptDirectory = false , callerPath ) {
50685082 if ( useScriptDirectory ) {
50695083 if ( callerPath ) {
@@ -5075,9 +5089,14 @@ function getBaseDirectory(useScriptDirectory = false, callerPath) {
50755089 console . log ( "Using __dirname:" , __dirname ) ;
50765090 return __dirname ;
50775091 }
5078- const moduleDir = ( 0 , import_path . dirname ) ( ( 0 , import_url . fileURLToPath ) ( __import_meta__ . url ) ) ;
5079- console . log ( "Using module directory:" , moduleDir ) ;
5080- return moduleDir ;
5092+ const modulePath = getCurrentModulePath ( ) ;
5093+ if ( modulePath ) {
5094+ const moduleDir = ( 0 , import_path . dirname ) ( modulePath ) ;
5095+ console . log ( "Using module directory:" , moduleDir ) ;
5096+ return moduleDir ;
5097+ }
5098+ console . log ( "Using current working directory:" , process . cwd ( ) ) ;
5099+ return process . cwd ( ) ;
50815100 }
50825101 const cwd = process . cwd ( ) ;
50835102 console . log ( "Using current working directory:" , cwd ) ;
@@ -5230,8 +5249,9 @@ module.exports = {
52305249 }
52315250}
52325251var mainScriptPath = import_path . default . resolve ( process . argv [ 1 ] || "" ) ;
5233- var currentScriptPath = ( 0 , import_url . fileURLToPath ) ( __import_meta__ . url ) ;
5234- if ( mainScriptPath === currentScriptPath ) {
5252+ var currentModulePath = getCurrentModulePath ( ) ;
5253+ var resolvedModulePath = currentModulePath ? import_path . default . resolve ( currentModulePath ) : void 0 ;
5254+ if ( resolvedModulePath && mainScriptPath === resolvedModulePath ) {
52355255 const jsonFilePath = process . argv [ 2 ] ;
52365256 const networkName = process . argv [ 3 ] ;
52375257 if ( ! jsonFilePath ) {
0 commit comments