MCPcopy
hub / github.com/qawolf/cli / runnerPathInDir

Function runnerPathInDir

src/domains/runner/initFlowRuntime.ts:29–57  ·  view source on GitHub ↗
(
  dir: string,
  fs: Fs,
)

Source from the content-addressed store, hash-verified

27 * re-throws any other error (e.g. malformed package.json, missing export).
28 */
29export async function runnerPathInDir(
30 dir: string,
31 fs: Fs,
32): Promise<string | undefined> {
33 const pkgPath = path.join(
34 dir,
35 "node_modules",
36 "@qawolf",
37 "flows",
38 "package.json",
39 );
40 try {
41 const pkg = JSON.parse(await fs.readFile(pkgPath)) as {
42 exports?: Record<string, { import?: string } | string>;
43 };
44 const entry = pkg.exports?.["./_runner"];
45 const importPath =
46 typeof entry === "object" && entry !== null ? entry.import : undefined;
47 if (typeof importPath !== "string") {
48 throw new Error(
49 `@qawolf/flows at ${pkgPath} does not export "./_runner" with an "import" condition`,
50 );
51 }
52 return path.resolve(path.dirname(pkgPath), importPath);
53 } catch (err) {
54 if (!isNoEntError(err)) throw err;
55 return undefined;
56 }
57}
58
59async function findFlowsRunnerPath(flowPath: string, fs: Fs): Promise<string> {
60 let dir = path.dirname(flowPath);

Callers 3

findFlowsRunnerPathFunction · 0.85
doInitFunction · 0.85

Calls 1

isNoEntErrorFunction · 0.85

Tested by

no test coverage detected