It's not clear your goal is simply to automate this for you, or if you want to determine the script method yourself.
However, there is an NPM package called inspect-process that automates the process of opening DevTools windows. ( Github ). It serves as a command line replacement for node . eg:
inspect myScript.js instead of node myScript.js
and it automatically opens the DevTools window.
If you need to script this process yourself, you can probably use the code from this package.
source share