relative
Easily calculate the relative path from file A to file B in Node.js project.
Calculates correctly from:
- File to directory
- File to file
- Directory to file
- Directory to directory
npm i relative --save
Usage
var relative = require('relative');
relative(from, to);
relative('test/fixtures/foo.txt', 'docs');
relative.toBase
Get the relative path from the given base path.
relative.toBase(basepath, filepath)
Example:
relative.toBase('one/two', 'one/two/three/four.json')
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license