relative
Get the relative filepath from path A to path B. Calculates from file-to-directory, file-to-file, directory-to-file, and directory-to-directory.
Calculates correctly from:
- File to directory
- File to file
- Directory to file
- Directory to directory
Install
Install with npm
npm i relative --save
Usage
var relative = require('relative');
relative(from, to);
relative('test/fixtures/foo.txt', 'docs');
API
Return the relative path from a
to b
.
from
{String}to
{String}returns
: {String}
Example:
var relative = require('relative');
relative('test/fixtures/foo.txt', 'docs/new/file.txt');
Get the path relative to the given base path.
basepath
{String}: The base directoryfilepath
{String}: The full filepathreturns
{String}: The relative path
Example:
relative.toBase('test/fixtures', 'test/fixtures/docs/new/file.txt');
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert
Released under the MIT license
This file was generated by verb on November 17, 2014.