Skip to content

Commit

Permalink
isNixOs: fix crash due to missing ID= field
Browse files Browse the repository at this point in the history
Assuming ID=linux by default.
Also removed toLowerCase — it really shouldn't be needed.
Fixes #11709
  • Loading branch information
cab404 committed Mar 15, 2022
1 parent 683fea4 commit b798e4d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions editors/code/src/main.ts
Expand Up @@ -269,8 +269,8 @@ function serverPath(config: Config): string | null {
async function isNixOs(): Promise<boolean> {
try {
const contents = (await vscode.workspace.fs.readFile(vscode.Uri.file("/etc/os-release"))).toString();
const idString = contents.split('\n').find((a) => a.startsWith("ID="));
return idString?.toLowerCase()?.indexOf("nixos") !== -1;
const idString = contents.split('\n').find((a) => a.startsWith("ID=")) || "ID=linux";
return idString.indexOf("nixos") !== -1;
} catch {
return false;
}
Expand Down

0 comments on commit b798e4d

Please sign in to comment.