Giter Site home page Giter Site logo

Comments (5)

bahmutov avatar bahmutov commented on September 16, 2024

You would like to find package.json somewhere between the current working
folder and the repo's root folder?

On Wed, Mar 11, 2015 at 4:24 PM, Tauren Mills [email protected]
wrote:

Do to a restriction outside of my control, we have a single git repo that
contains multiple node projects. The repo is structured like this:

/.git
/project1
/project1/package.json
/project1/node_modules
/project2/package.json
/project2/node_modules

The pre-git hooks assume that there is only one package.json and that it
is in the same directory as the .git folder. What would be involved in
getting the hook to walk up the directory tree and locate the first
package.json? This would allow me to run git commit in the /project1
directory and find its package.json instead of throwing an error that the
file doesn't exist.


Reply to this email directly or view it on GitHub
#20.

from pre-git.

tauren avatar tauren commented on September 16, 2024

Yes. Either in the current working directory, or a parent of it, up to the repo's root folder.

I just noticed support for pre-git-cwd and am messing with it.

from pre-git.

tauren avatar tauren commented on September 16, 2024

pre-git-cwd won't work since it is a setting within package.json, which is what I'm trying to locate and haven't loaded yet.

from pre-git.

tauren avatar tauren commented on September 16, 2024

https://github.com/indexzero/node-pkginfo is a popular package that will locate and load the package.json file. Since I assume the hook scripts shouldn't have dependencies, the code could be borrowed from here:
https://github.com/indexzero/node-pkginfo/blob/master/lib/pkginfo.js#L90

If I implemented this, would you accept a PR?

from pre-git.

bahmutov avatar bahmutov commented on September 16, 2024

I think this works now, I released it as 0.2.0 and added you to the list of contributors in the package.json. Thank you for this feature.

from pre-git.

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.