MCPcopy
hub / github.com/browserless/browserless / getSourceFiles

Function getSourceFiles

src/sdk-utils.ts:66–96  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

64};
65
66export const getSourceFiles = async (cwd: string) => {
67 const buildDir = path.join(cwd, 'build');
68 const files = await fs.readdir(buildDir, { recursive: true });
69 const [httpRoutes, webSocketRoutes] = files.reduce(
70 ([httpRoutes, webSocketRoutes], file) => {
71 const parsed = path.parse(file);
72 const pathSegments = file.split(path.sep);
73
74 if (pathSegments.some((segment) => ignore.includes(segment))) {
75 return [httpRoutes, webSocketRoutes];
76 }
77
78 if (parsed.name.endsWith('http')) {
79 httpRoutes.push(path.join(buildDir, file));
80 }
81
82 if (parsed.name.endsWith('ws')) {
83 webSocketRoutes.push(path.join(buildDir, file));
84 }
85
86 return [httpRoutes, webSocketRoutes];
87 },
88 [[] as string[], [] as string[]],
89 );
90
91 return {
92 files,
93 httpRoutes,
94 webSocketRoutes,
95 };
96};
97
98export const camelCase = (str: string) =>
99 str.replace(/-([a-z])/g, (_, w) => w.toUpperCase());

Callers 2

buildFunction · 0.85
startFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected