Skip to content

Commit 148e71f

Browse files
committed
refactor(pmdb): pmdb can be enabled outside of pmjs
Simply call `from pythonmonkey.lib import pmdb; pmdb.enable()`
1 parent e716cd0 commit 148e71f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

python/pythonmonkey/cli/pmjs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys, os, signal, getopt
77
import readline
88
import pythonmonkey as pm
9-
from pythonmonkey.lib.pmdb import pmdbEnable
9+
from pythonmonkey.lib import pmdb
1010

1111
globalThis = pm.eval("globalThis")
1212
evalOpts = { 'filename': __file__, 'fromPythonFrame': True, 'strict': False } # type: pm.EvalOptions
@@ -351,7 +351,7 @@ def main():
351351
elif o in ("-r", "--require"):
352352
globalThis.require(a)
353353
elif o in ("--inspect"):
354-
pmdbEnable(pm.eval("debuggerGlobal"))
354+
pmdb.enable()
355355
else:
356356
assert False, "unhandled option"
357357

python/pythonmonkey/lib/pmdb.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# @file pmdb - A gdb-like JavaScript debugger interface for pmjs
2-
# Enabled by `pmjs --inspect`
1+
# @file pmdb - A gdb-like JavaScript debugger interface
32
# @author Tom Tang <[email protected]>
43
# @date July 2023
54

5+
import pythonmonkey as pm
6+
67
def debuggerInput(prompt: str):
78
try:
89
return input(prompt) # blocking
@@ -13,7 +14,7 @@ def debuggerInput(prompt: str):
1314
print(e)
1415
return ""
1516

16-
def pmdbEnable(debuggerGlobalObject):
17+
def enable(debuggerGlobalObject = pm.eval("debuggerGlobal")):
1718
debuggerGlobalObject.eval("""(debuggerInput, _pythonPrint) => {
1819
const dbg = new Debugger()
1920
const mainDebuggee = dbg.addDebuggee(mainGlobal)

0 commit comments

Comments
 (0)