()
| 4 | const appAsarRegexp = new RegExp(`\\${path.sep}app\\.asar\\${path.sep}`, 'g'); |
| 5 | |
| 6 | export function resolveLibPath(): string |
| 7 | { |
| 8 | const defaultLibPath = path.resolve(__dirname, '..', 'brainflow', 'lib'); |
| 9 | const electronProcess = process as NodeJS.Process & {resourcesPath?: string}; |
| 10 | const searchRoots = [ |
| 11 | __dirname, |
| 12 | __dirname.replace(appAsarRegexp, `${path.sep}app.asar.unpacked${path.sep}`), |
| 13 | typeof electronProcess.resourcesPath === 'string' ? electronProcess.resourcesPath : '', |
| 14 | ].filter(Boolean); |
| 15 | |
| 16 | const libPathCandidates = [ |
| 17 | defaultLibPath, |
| 18 | ...searchRoots.flatMap((root) => [ |
| 19 | path.resolve(root, '..', 'brainflow', 'lib'), |
| 20 | path.resolve(root, '..', 'node_modules', 'brainflow', 'brainflow', 'lib'), |
| 21 | path.resolve(root, 'node_modules', 'brainflow', 'brainflow', 'lib'), |
| 22 | path.resolve(root, 'app.asar.unpacked', 'node_modules', 'brainflow', 'brainflow', 'lib'), |
| 23 | ]), |
| 24 | ]; |
| 25 | |
| 26 | const existingPath = libPathCandidates.find((candidate) => fs.existsSync(candidate)); |
| 27 | return existingPath || defaultLibPath; |
| 28 | } |
no outgoing calls
no test coverage detected