MCPcopy
hub / github.com/smapiot/piral / getLocalPackageDir

Function getLocalPackageDir

src/tooling/piral-cli/src/plugin.ts:18–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16}
17
18async function getLocalPackageDir() {
19 const proposedDirs = [
20 getContainerDir(),
21 resolve(process.cwd(), 'node_modules'),
22 resolve(process.cwd(), '..', 'node_modules'),
23 resolve(process.cwd(), '..', '..', 'node_modules'),
24 resolve(process.cwd(), '..', '..', '..', 'node_modules'),
25 ];
26
27 // Right now we always take the first one, but in the future this may be different
28 // once we come up with more / better criteria to identify if its a good/valid
29 // plugin root directory
30 for (const dir of proposedDirs.filter(Boolean)) {
31 log('generalDebug_0003', `Checking for potential plugin directory "${dir}" ...`);
32
33 if (await isValidModulesDirectory(dir)) {
34 return dir;
35 }
36 }
37
38 return undefined;
39}
40
41function isValidModulesDirectory(dir: string) {
42 return isDirectory(resolve(dir, 'piral-cli'));

Callers 1

loadPluginsFunction · 0.85

Calls 5

logFunction · 0.90
getContainerDirFunction · 0.85
resolveFunction · 0.85
isValidModulesDirectoryFunction · 0.85
filterMethod · 0.65

Tested by

no test coverage detected