Code coverage report for src/utils.ts

# All files / src utils.ts

80% Statements 12/15
90% Branches 9/10
80% Functions 4/5
78.57% Lines 11/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    302x
    2x

    2x

    2x

    6x
    11x

    6x
    1x

    5x

    2x
    16x

     import * as vscode from 'vscode';
    import { normalize } from 'path';
    // @ts-ignore
    import * as commondir from 'commondir';

    export function getRootPath() {
      const absolutePathsOfWorkspaceFolders =
        vscode.workspace.workspaceFolders?.map(
          (workspaceFolder) => workspaceFolder.uri.fsPath
        ) || [];

      if (absolutePathsOfWorkspaceFolders.length === 0) {
        return;
      }

      return absolutePathsOfWorkspaceFolders.length > 0
        ? normalize(commondir(absolutePathsOfWorkspaceFolders))
        : undefined;
    }

    export function withErrorHandler(errorHandler: (error: Error) => void) {
      return (fn: Function) => (...args: any[]) => {
        try {
          return fn(...args);
        } catch (error) {
          errorHandler(error);
        }
      };
    }