11710:  editors/code: fix crash due to missing ID= field r=lnicola a=cab404

Assuming ID=linux by default.
Also removed toLowerCase — it really shouldn't be needed.
Fixes #11709

Co-authored-by: Vladimir Serov <me@cab404.ru>
This commit is contained in:
bors[bot] 2022-03-15 07:27:05 +00:00 committed by GitHub
commit 88ade42039
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}