Reputation: 8943
I have an npm module I develop. I want to know which version of this module is being used across the different projects in my company's organization repository. Is there a way to run a search for a specific versions of a module?
For example my latest version of the module is "5.x.x"
. I want to find all usages that are not "^5.x.x"
.
I tried searching for filename:package.json my-module
but this gives me too many results, which most of them is the latest version ("^5.x.x"
).
Maybe there is some other way to achieve it which is not the Github search?
Edit:
Upvotes: 4
Views: 1303
Reputation: 3726
You can use find
and grep
commands in Bash:
$ cd path/to/your/repo
$ find . -name package.json | xargs grep '"my_module":'
This command lists all lines with your module in all package.json files across the repository. If this yields too many results, you can grep
some more, for example:
$ find . -name package.json | xargs grep '"my_module":' | grep -v '\^5\.'
which excludes any lines mentioning your module with major version number of 5.
Upvotes: 1
Reputation: 70125
Given the restrictions placed on GitHub search, it's unlikely you'll be able to easily do this in the GitHub interface.
If you have all your repositories cloned inside a single directory and you're on a UNIX-like operating system, you can use grep
(or do all kinds of programmatic searches):
grep '"my-module": ' */package.json | grep -v '"\^5\.'
The above assumes that the entry starts with ^
and not ~
or a digit. Modify as needed. In your case, it's probably fine. If it isn't, it will show some version 5 instances, which is better than having it not show earlier instances.
Upvotes: 1