Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

std/path/relative.ts

The Deno Standard Library
Latest
File
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.
import { isWindows } from "./_os.ts";import { relative as posixRelative } from "./posix/relative.ts";import { relative as windowsRelative } from "./windows/relative.ts";
/** * Return the relative path from `from` to `to` based on current working directory. * * An example in windws, for instance: * from = 'C:\\orandea\\test\\aaa' * to = 'C:\\orandea\\impl\\bbb' * The output of the function should be: '..\\..\\impl\\bbb' * * @param from path in current working directory * @param to path in current working directory */export function relative(from: string, to: string): string { return isWindows ? windowsRelative(from, to) : posixRelative(from, to);}