UNPKG

@oazmi/build-tools

Version:

general deno build tool scripts which I practically use in all of my typescript repos

36 lines (35 loc) 1.03 kB
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. import { _common } from "./_common/common.js"; import { SEPARATOR } from "./constants.js"; /** * Determines the common path from a set of paths, using an optional separator, * which defaults to the OS default separator. * * @param paths Paths to search for common path. * @param sep Path separator to use. * @returns The common path. * * @example Usage * ```ts * import { common } from "@std/path/common"; * import { assertEquals } from "@std/assert/assert-equals"; * * if (Deno.build.os === "windows") { * const path = common([ * "C:\\deno\\std\\path\\mod.ts", * "C:\\deno\\std\\fs\\mod.ts" * ]); * assertEquals(path, "C:\\deno\\std\\"); * } else { * const path = common([ * "./deno/std/path/mod.ts", * "./deno/std/fs/mod.ts" * ]); * assertEquals(path, "./deno/std/"); * } * ``` */ export function common(paths, sep = SEPARATOR) { return _common(paths, sep); }