keep-a-changelog
Version:
Node package to parse and generate changelogs following the [keepachangelog](https://keepachangelog.com/) format.
34 lines (33 loc) • 1.19 kB
JavaScript
;
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
Object.defineProperty(exports, "__esModule", { value: true });
exports.relative = relative;
const _os_js_1 = require("./_os.js");
const relative_js_1 = require("./posix/relative.js");
const relative_js_2 = require("./windows/relative.js");
/**
* Return the relative path from `from` to `to` based on current working
* directory.
*
* @example Usage
* ```ts
* import { relative } from "@std/path/relative";
* import { assertEquals } from "@std/assert";
*
* if (Deno.build.os === "windows") {
* const path = relative("C:\\foobar\\test\\aaa", "C:\\foobar\\impl\\bbb");
* assertEquals(path, "..\\..\\impl\\bbb");
* } else {
* const path = relative("/data/foobar/test/aaa", "/data/foobar/impl/bbb");
* assertEquals(path, "../../impl/bbb");
* }
* ```
*
* @param from Path in current working directory.
* @param to Path in current working directory.
* @returns The relative path from `from` to `to`.
*/
function relative(from, to) {
return _os_js_1.isWindows ? (0, relative_js_2.relative)(from, to) : (0, relative_js_1.relative)(from, to);
}