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

fix(vscode): disable extension if required config file is missing #210

Merged
merged 4 commits into from
Sep 9, 2023
Merged
Changes from all commits
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
21 changes: 21 additions & 0 deletions editors/vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ export async function activate(context: ExtensionContext) {
const outputChannel = window.createOutputChannel("Biome");
const traceOutputChannel = window.createOutputChannel("Biome Trace");

const requiresConfiguration = workspace
.getConfiguration("biome")
.get<boolean>("requireConfiguration");

// If the extension requires a configuration file to be present, we attempt to
// locate it. If a config file cannot be found, we do not go any further.
if (requiresConfiguration) {
outputChannel.appendLine("Configuration file required, looking for one.");
// TODO: Stop looking for rome.json when we reach biome v2.0
const configFiles = await workspace.findFiles("**/{biome,rome}.json");
if (configFiles.length === 0) {
outputChannel.appendLine(
"No config file found, disabling Biome extension",
);
return;
}
outputChannel.appendLine(
`Config file found at ${configFiles[0].fsPath}, enabling Biome extension`,
);
}

const command = await getServerPath(context, outputChannel);

if (!command) {
Expand Down