Skip to content

Commit

Permalink
fix(vscode): disable extension if required config file is missing (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhedger authored Sep 9, 2023
1 parent c9c7db6 commit 7ede9d5
Showing 1 changed file with 21 additions and 0 deletions.
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

0 comments on commit 7ede9d5

Please sign in to comment.