Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require a global install of cadl for the IDE extension to work #1197

Merged
merged 5 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/cadl-vs/src/Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public CadlServerNotFoundException(string fileName, Exception? innerException =
: base(string.Join("\n", new string[]
{
$"Cadl server executable was not found: '{fileName}' is not found. Make sure either:",
" - cadl is installed locally at the root of this workspace.",
" - cadl is installed locally at the root of this workspace or in a parent directory.",
" - cadl is installed globally with `npm install -g @cadl-lang/compiler'.",
" - cadl server path is configured with https://github.com/microsoft/cadl/blob/main/packages/cadl-vs/README.md#configure-cadl-visual-studio-extension."
}, innerException))
}), innerException)
timotheeguerin marked this conversation as resolved.
Show resolved Hide resolved
{
}
}
Expand Down
11 changes: 8 additions & 3 deletions packages/cadl-vs/src/VSExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,15 @@ private static string GetDevelopmentCadlServerPath()

private string? ResolveLocalCompiler(string baseDir)
{
var potentialLocation = Path.Combine(baseDir, "node_modules/@cadl-lang/compiler");
if (Directory.Exists(potentialLocation))
var current = baseDir;
while (current != null)
{
return potentialLocation;
var potentialInstallDir = Path.Combine(current, "node_modules", "@cadl-lang", "compiler");
if (Directory.Exists(potentialInstallDir))
{
return potentialInstallDir;
}
current = Path.GetDirectoryName(current);
}
return null;
}
Expand Down