Skip to content

Commit e013e32

Browse files
authored
Support esy in monorepos (#440)
1 parent f7d7a28 commit e013e32

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/analyze/BuildSystem.re

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ let detectFull = projectDir => {
197197
};
198198
};
199199

200-
let getEsyCompiledBase = () => {
200+
let getEsyCompiledBase = (rootPath) => {
201201
let env = Unix.environment()->Array.to_list;
202202

203203
switch(Utils.getEnvVar(~env, "cur__original_root"), Utils.getEnvVar(~env, "cur__target_dir")) {
204204
| (Some(projectRoot), Some(targetDir)) => Ok(Files.relpath(projectRoot, targetDir))
205205
| (_, _) =>
206-
switch (Commands.execResult("esy command-env --json")) {
206+
switch (Commands.execResult("cd " ++ rootPath ++ " && esy command-env --json")) {
207207
| Ok(commandEnv) =>
208208
switch (Json.parse(commandEnv)) {
209209
| exception (Failure(message)) =>
@@ -239,7 +239,7 @@ let getCompiledBase = (root, buildSystem) => {
239239
| BsbNative(_, Bytecode) => Ok(root /+ "lib" /+ "bs" /+ "bytecode")
240240
| Dune(Opam(_)) => Ok(root /+ "_build") /* TODO maybe check DUNE_BUILD_DIR */
241241
| Dune(Esy(_)) =>
242-
let%try_wrap esyTargetDir = getEsyCompiledBase();
242+
let%try_wrap esyTargetDir = getEsyCompiledBase(root);
243243
root /+ esyTargetDir
244244
};
245245

@@ -384,7 +384,7 @@ let hiddenLocation = (rootPath, buildSystem) => {
384384
| BsbNative(_, _) => Ok(rootPath /+ "node_modules" /+ ".lsp")
385385
| Dune(Opam(_)) => Ok(rootPath /+ "_build" /+ ".lsp")
386386
| Dune(Esy(_)) =>
387-
let%try_wrap esyTargetDir = getEsyCompiledBase();
387+
let%try_wrap esyTargetDir = getEsyCompiledBase(rootPath);
388388
rootPath /+ esyTargetDir /+ ".lsp"
389389
};
390390
};

0 commit comments

Comments
 (0)