'How do dynamically and programmatically add a debug configuration in a vscode debugger extension?

We have a VSCode debugger extension. It allows debugging of things happening on a connected device (iOS/Android/...). We have a nodejs native addon capable of detecting when devices connect and disconnect and calling a custom JS/TS callback when this happens.

rpc.setOnDeviceAddedCallback((deviceId: string) => {
    console.log('deviceAdded: ' + deviceId);
}); 

The user already has his folder opened.

Question: How can I, in the above callback access the inMemory values of launch.json or equivalent to dynamically add a debug configuration in the below dropdown?

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source