Skip to content

Commit 01a4a81

Browse files
authored
Merge pull request #1126 from nojaf/pnpm
Add support for pnpm
2 parents 3d9a6d9 + 72b0867 commit 01a4a81

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

server/src/find-runtime.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,17 @@ async function findNodeModulesDirs(
5151
return nodeModulesDirs;
5252
}
5353

54-
// Custom function to find Deno vendorized @rescript/runtime directories
55-
async function findDenoRescriptRuntime(nodeModulesPath: string) {
54+
// Custom function to find Deno or pnpm vendorized @rescript/runtime directories
55+
async function findRescriptRuntimeInAlternativeLayout(
56+
subfolder: ".deno" | ".pnpm",
57+
nodeModulesPath: string,
58+
) {
5659
// We only care about the Deno vendorized layout:
5760
// <nodeModulesPath>/.deno/@rescript+runtime@<version>/node_modules/@rescript/runtime
58-
const denoRoot = join(nodeModulesPath, ".deno");
61+
const alternativeRoot = join(nodeModulesPath, subfolder);
5962
let entries: string[];
6063
try {
61-
entries = await readdir(denoRoot);
64+
entries = await readdir(alternativeRoot);
6265
} catch {
6366
return [];
6467
}
@@ -71,7 +74,7 @@ async function findDenoRescriptRuntime(nodeModulesPath: string) {
7174
const results: string[] = [];
7275
for (const dir of vendorDirs) {
7376
const runtimePath = join(
74-
denoRoot,
77+
alternativeRoot,
7578
dir,
7679
"node_modules",
7780
"@rescript",
@@ -102,15 +105,28 @@ async function findRuntimePath(project: string) {
102105
const stat = await statAsync(standardPath);
103106
if (stat.isDirectory()) {
104107
results.push(standardPath);
105-
// If we found standard layout, no need to search for Deno layouts
108+
// If we found standard layout, no need to search for pnpm or Deno layouts
106109
return results;
107110
}
108111
} catch (e) {
109112
// Directory doesn't exist, continue
110113
}
111114

115+
// Only check for pnpm vendorized layouts if standard layout wasn't found
116+
const pnpmResults = await findRescriptRuntimeInAlternativeLayout(
117+
".pnpm",
118+
nm,
119+
);
120+
results.push(...pnpmResults);
121+
if (results.length > 0) {
122+
return results;
123+
}
124+
112125
// Only check for Deno vendorized layouts if standard layout wasn't found
113-
const denoResults = await findDenoRescriptRuntime(nm);
126+
const denoResults = await findRescriptRuntimeInAlternativeLayout(
127+
".deno",
128+
nm,
129+
);
114130
results.push(...denoResults);
115131

116132
return results;

0 commit comments

Comments
 (0)