@oazmi/build-tools
Version:
general deno build tool scripts which I practically use in all of my typescript repos
27 lines (26 loc) • 931 B
JavaScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
import { isWindows } from "./_os.js";
import { join as posixJoin } from "./posix/join.js";
import { join as windowsJoin } from "./windows/join.js";
/**
* Join all given a sequence of paths, then normalizes the resulting path.
*
* @example Usage
* ```ts
* import { join } from "@std/path/join";
* import { assertEquals } from "@std/assert/assert-equals";
*
* if (Deno.build.os === "windows") {
* assertEquals(join("C:\\foo", "bar", "baz\\quux", "garply", ".."), "C:\\foo\\bar\\baz\\quux");
* } else {
* assertEquals(join("/foo", "bar", "baz/quux", "garply", ".."), "/foo/bar/baz/quux");
* }
* ```
*
* @param paths Paths to be joined and normalized.
* @returns The joined and normalized path.
*/
export function join(...paths) {
return isWindows ? windowsJoin(...paths) : posixJoin(...paths);
}