Giter Site home page Giter Site logo

Comments (6)

inxilpro avatar inxilpro commented on July 29, 2024

Can you give me a use case where you'd want to include it in a library that's required by something else? When I put it together, I considered doing a recursive loop up the path, but decided it was unnecessary because it was solving a problem that I didn't thin would ever come up. That said, I can be convinced.

from node-app-root-path.

Californian avatar Californian commented on July 29, 2024

Well to be honest, I won't be doing that any time soon. However, this is a very generally-useful module, and could potentially be used in a lot of others (which are used by still other modules), so I thought it would be a nice little contribution I could make.

from node-app-root-path.

inxilpro avatar inxilpro commented on July 29, 2024

Here's another possible solution:

var root = path.resolve(__dirname).split('node_modules', 1)[0];

That would take something like this:

/var/www/node_modules/mymod/node_modules/node-app-root-path/

And split it into ["/var/www/"] — then you'd just grab the first element in the array.

Can you see any issue with that?

from node-app-root-path.

Californian avatar Californian commented on July 29, 2024

Awesome, so clean and simple! That seems like a better solution even, in case it somehow has an extra folder between one node_modules and the next one.

from node-app-root-path.

inxilpro avatar inxilpro commented on July 29, 2024

I actually went ahead and rewrote a bunch of it to account for most edge cases. Take a look at:

https://github.com/inxilpro/node-app-root-path/tree/feature/comprehensive-resolution

from node-app-root-path.

inxilpro avatar inxilpro commented on July 29, 2024

0.1.0 has been released, which fixes this.

from node-app-root-path.

Related Issues (20)

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.