(extensionPath: string, useModule)
| 15 | } |
| 16 | |
| 17 | export 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 | |
| 44 | declare function __webpack_require__(name: string): any; |
| 45 | declare function __non_webpack_require__(name: string): any; |
no test coverage detected