Coder Social home page Coder Social logo

jonschlinkert / relative Goto Github PK

View Code? Open in Web Editor NEW
34.0 34.0 7.0 221 KB

Easily calculate the relative path from file A to file B in Node.js project. Will calculate correctly from a file to a directory, file to file, directory to file, and directory to directory.

Home Page: https://github.com/jonschlinkert

License: MIT License

JavaScript 100.00%
path relative

relative's People

Contributors

doowb avatar dulacp avatar jonschlinkert avatar popomore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

relative's Issues

Issue with folder names and dots

Hi,

We noticed a little issue when using relative and folder names that contain dots.

To reproduce:

  1. create a folder with a few dots: my.super.project with the file resources/data/accordion.json in it
  2. execute this:
var relative = require('relative');
console.log(relative(process.cwd(), '/Users/username/my.super.project/resources/data/accordion.json'));

expected: resources/data/accordion.json
result: my.super.project/resources/data/accordion.json

Files at same level don't include preceding dot

If the two files being compared are at the same level in the file structure, the relative path is not preceded by a ./

For example:

 myFolder
   file1
   file2
var output = relative(file1path, file2path)
console.log(output)
'file2'

I would have expected the output to instead be: ./file2

Is there a reason why it isn't like this?

Thanks very much for the otherwise excellent package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.