Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finding extra package.json files #45

Open
juanpaco opened this issue Apr 21, 2016 · 7 comments
Open

Finding extra package.json files #45

juanpaco opened this issue Apr 21, 2016 · 7 comments

Comments

@juanpaco
Copy link

In my project we run all the code through a build process that dumps the output into a build directory off the project root. This directory is happily git ignored and all.

However, if I'm reading it right, because find is recursive (https://github.com/nlf/git-validate/blob/master/bin/validate.sh#L339), it picks up this other package.json and tries to run the validations from within that build directory. This leads to failures due to missing dependencies, which I expect. I don't want to run the validations against the build directory.

I'm not entirely sure what the best approach to fixing this would be. I assume there's a reason why max-depth of 1 wouldn't be appropriate, but at the same time, I'd rather not delete my build just to lint my project. I'm not sure this is even a "bug" with git-validate.

Do you have any guidance on this? I'd hate to add another config file to the project's root. I suppose I could move the build directory outside of the project, but I like everything being self-contained as well.

@nlf
Copy link
Owner

nlf commented Oct 7, 2016

what if i added a config field to package.json so you could do something like

{
  'git-validate': {
    ignore: 'build'
  }
}

and any packages found in the 'build' directory (which would be a direct child of the current directory, i'd just use path.join with the root) would be ignored. sound ok?

@nlf nlf added the enhancement label Oct 7, 2016
@juanpaco
Copy link
Author

juanpaco commented Oct 7, 2016

That sounds like a great solution. Thank you!

@nerdgore
Copy link

nerdgore commented Nov 15, 2016

This solution would only be suboptimal. Since I git-validate is used to create modules that configure your project to use hooks, the module can't know upfront what to ignore.
IMO a better approach would be to limit the search scope to .git/../

@nerdgore
Copy link

My suggestion to look for package.json:

    local projects;
    projects=$(find . -maxdepth 1 -name package.json -print 2>/dev/null)
    if [[ $? -ne 0 ]]; then
        projects=$(find . -not -iwholename '*node_modules*' -not -iwholename '*bower_components*' -maxdepth 3 -name package.json -print 2>/dev/null)
    fi
    if [[ $? -ne 0 ]]; then
        projects=$(find . -not -ipath '*node_modules*' -not -ipath '*bower_components*' -maxdepth 3 -name package.json -print 2>/dev/null)
    fi

If you don't find a package.json at the root level continue to dig deeper.

@nlf
Copy link
Owner

nlf commented Nov 28, 2016

thinking about using git ls-files instead so that anything that's not committed to the repo won't be found, this solves the problem of node_modules and of things that are .gitignored

thoughts?

@nlf
Copy link
Owner

nlf commented Nov 28, 2016

noting that i'll still filter out node_modules since some people commit those

@Trainmaster
Copy link

@nlf Any update on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants