Skip to content

Commit

Permalink
Support esy in monorepos (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer authored Jun 25, 2020
1 parent f7d7a28 commit e013e32
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/analyze/BuildSystem.re
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ let detectFull = projectDir => {
};
};

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

switch(Utils.getEnvVar(~env, "cur__original_root"), Utils.getEnvVar(~env, "cur__target_dir")) {
| (Some(projectRoot), Some(targetDir)) => Ok(Files.relpath(projectRoot, targetDir))
| (_, _) =>
switch (Commands.execResult("esy command-env --json")) {
switch (Commands.execResult("cd " ++ rootPath ++ " && esy command-env --json")) {
| Ok(commandEnv) =>
switch (Json.parse(commandEnv)) {
| exception (Failure(message)) =>
Expand Down Expand Up @@ -239,7 +239,7 @@ let getCompiledBase = (root, buildSystem) => {
| BsbNative(_, Bytecode) => Ok(root /+ "lib" /+ "bs" /+ "bytecode")
| Dune(Opam(_)) => Ok(root /+ "_build") /* TODO maybe check DUNE_BUILD_DIR */
| Dune(Esy(_)) =>
let%try_wrap esyTargetDir = getEsyCompiledBase();
let%try_wrap esyTargetDir = getEsyCompiledBase(root);
root /+ esyTargetDir
};

Expand Down Expand Up @@ -384,7 +384,7 @@ let hiddenLocation = (rootPath, buildSystem) => {
| BsbNative(_, _) => Ok(rootPath /+ "node_modules" /+ ".lsp")
| Dune(Opam(_)) => Ok(rootPath /+ "_build" /+ ".lsp")
| Dune(Esy(_)) =>
let%try_wrap esyTargetDir = getEsyCompiledBase();
let%try_wrap esyTargetDir = getEsyCompiledBase(rootPath);
rootPath /+ esyTargetDir /+ ".lsp"
};
};
Expand Down

0 comments on commit e013e32

Please sign in to comment.