All files union-env-path.ts

100% Statements 20/20
100% Branches 3/3
100% Functions 2/2
100% Lines 20/20

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 211x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x  
/**
 * Copyright (c) OpenLens Authors. All rights reserved.
 * Licensed under MIT License. See LICENSE in root directory for more information.
 */
 
import path from "path";
import { iter } from "./iter";
 
/**
 * Join all entires with a PATH env var delimited string together
 * @param PATHs Any number of PATH env variables
 *
 * NOTE: This function does not attempt to handle any sort of escape sequences since after testing
 * it was found that `zsh` (at least on `macOS`) does not when trying to find programs
 */
export function unionPATHs(...PATHs: string[]): string {
  const entries = new Set(iter.filterFlatMap(PATHs, PATH => PATH.split(path.delimiter)));
 
  return iter.join(entries.values(), path.delimiter);
}