MCPcopy Create free account
hub / github.com/Marus/cortex-debug / findSerialPortModule

Function findSerialPortModule

src/frontend/swo/sources/serial.ts:17–42  ·  view source on GitHub ↗
(extensionPath: string, useModule)

Source from the content-addressed store, hash-verified

15}
16
17export function findSerialPortModule(extensionPath: string, useModule) {
18 const paths = [];
19 const p = path.normalize(path.join(extensionPath, 'binary_modules', 'electron-' + process.versions['electron'], 'node_modules'));
20 if (fs.existsSync(p) && fs.existsSync(path.join(p, 'serialport'))) {
21 paths.push(p);
22 } else {
23 const serMonitorExt = 'ms-vscode.vscode-serial-monitor';
24 const serialMonitor: vscode.Extension<any> = vscode.extensions.getExtension(serMonitorExt);
25 if (serialMonitor) {
26 paths.push(path.join(serialMonitor.extensionPath, 'dist', 'node_modules'));
27 paths.push(path.join(serialMonitor.extensionPath, 'node_modules'));
28 }
29 }
30
31 let added = false;
32 for (const p of paths) {
33 if (fs.existsSync(path.join(p, 'serialport'))) {
34 if (useModule.paths.indexOf(p) === -1) {
35 console.log(`Adding ${p} to module search path`);
36 useModule.paths.push(p);
37 }
38 added = true;
39 }
40 }
41 return added;
42}
43
44declare function __webpack_require__(name: string): any;
45declare function __non_webpack_require__(name: string): any;

Callers 2

serialport.test.tsFile · 0.90
constructorMethod · 0.85

Calls 2

normalizeMethod · 0.80
logMethod · 0.80

Tested by

no test coverage detected