Browse Source

Updated JSRequire to populate the module.filename property so that it's available to the debugger API

Shaddock Heath 9 years ago
parent
commit
addec6dd30
1 changed files with 10 additions and 0 deletions
  1. 10 0
      Source/AtomicJS/Javascript/JSRequire.cpp

+ 10 - 0
Source/AtomicJS/Javascript/JSRequire.cpp

@@ -150,6 +150,16 @@ namespace Atomic
 
         if (cache->Exists(path))
         {
+            // We're a module w/o an associated filename, so we need
+            // to provide the fully qualified filename path so the debugger
+            // can resolve to a file correctly
+            if (duk_is_object(ctx, 3) &&
+                    !duk_has_prop_string(ctx, 3, "filename"))
+            {
+                duk_push_string(ctx, path.CString());
+                duk_put_prop_string(ctx, 3, "filename");
+            }
+
             SharedPtr<File> jsfile(cache->GetFile(path, false));
             vm->SetLastModuleSearchFile(jsfile->GetFullPath());
             String source;