LCOV - code coverage report
Current view: top level - pkg/lib - os-release.ts Coverage Total Hit
Test: cockpit Lines: 100.0 % 16 16
Test Date: 2026-07-13 10:00:01

            Line data    Source code
       1              : /*
       2              :  * Copyright (C) 2022 Red Hat, Inc.
       3              :  * SPDX-License-Identifier: LGPL-2.1-or-later
       4              :  */
       5              : 
       6          531 : import cockpit from "cockpit";
       7              : 
       8          460 : function parse_simple_vars(text: string): Record<string, string> {
       9          460 :     const res: Record<string, string> = { };
      10          460 :     for (const l of text.split('\n')) {
      11          460 :         const pos = l.indexOf('=');
      12          460 :         if (pos > 0) {
      13          460 :             const name = l.substring(0, pos);
      14          460 :             let val = l.substring(pos + 1);
      15          460 :             if (val[0] == '"' && val[val.length - 1] == '"')
      16          460 :                 val = val.substring(1, val.length - 1);
      17          460 :             res[name] = val;
      18          460 :         }
      19          460 :     }
      20          460 :     return res;
      21          460 : }
      22              : 
      23              : /* Return /etc/os-release as object */
      24          461 : export const read_os_release = () => cockpit.file("/etc/os-release", { syntax: { parse: parse_simple_vars } }).read();
        

Generated by: LCOV version 2.0-1