editors/code: fix crash due to missing ID= field

Assuming ID=linux in isNixOs by default. You can get away with
default "", but why do that if there's a default value in spec?)

Also removed toLowerCase — it really shouldn't be needed.
Fixes #11709
This commit is contained in:
Vladimir Serov 2022-03-15 06:52:03 +03:00
parent 683fea4de4
commit f7cf3b5503
No known key found for this signature in database
GPG key ID: 08AA9711F8CD40CF

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