MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / resolveLibPath

Function resolveLibPath

nodejs_package/brainflow/lib_path.ts:6–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4const appAsarRegexp = new RegExp(`\\${path.sep}app\\.asar\\${path.sep}`, 'g');
5
6export 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}

Callers 3

constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected