utilities.js 459 B

12345678910111213141516171819
  1. export function parseMountPointFromConfig(content) {
  2. for (const line of content.split('\n')) {
  3. // Skip comment lines
  4. if (/^\s*#/.test(line)) {
  5. continue;
  6. }
  7. // Match root at start of line (after optional whitespace)
  8. const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
  9. if (!match) {
  10. continue;
  11. }
  12. return match.groups.mountPoint
  13. .trim()
  14. // Strip surrounding quotes
  15. .replaceAll(/^["']|["']$/g, '');
  16. }
  17. }