-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[DOCS] npm search --long flag has no effect #7434
Comments
I recovered the "expected" behavior with only a few small changes to class Search extends BaseCommand {
// ...
async exec (args) {
const opts = {
...this.npm.flatOptions,
...this.npm.flatOptions.search,
detailed: true, // NEW: request full response from search API
include: args.map(s => s.toLowerCase()).filter(s => s),
exclude: this.npm.flatOptions.search.exclude.split(/\s+/),
}
// NEW: long is not in flatOptions
const returnLong = this.npm.config.get('long');
if (opts.include.length === 0) {
throw new Error('search must be called with arguments')
}
// Used later to figure out whether we had any packages go out
let anyOutput = false
class FilterStream extends Minipass {
constructor () {
super({ objectMode: true })
console.log(opts);
}
write (pkg) {
// NEW: pkg now contains a package prop plus extra info
if (filter(pkg.package, opts.include, opts.exclude)) {
// NEW: only JSON output supports extra fields
super.write((returnLong && opts.json) ? pkg : pkg.package)
}
}
}
// ... class continues
} This would add support for On the other hand, it would also make loads of sense to just remove the |
I thing As far as adding those flags, that'd be a separate feature request. I don't thing popularity is likely to be added, but I think adding an extra line of caution if |
Closing this as it's not a bug, but if someone wants to submit a PR to add something if |
Reopening cause we should remove this from the params |
Nice job :) |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
This could also be a feature request or a docs update depending how you look at it...
When calling
npm search
with the--long
flag, e.g.> npm search --long --json --searchlimit 1 color
I get this output, which is identical to calling search without
--long
Expected Behavior
I expected more information, perhaps the full output of registry search
For example
> npm search --long --json --searchlimit 1 color
Steps To Reproduce
Run the commands above. I've checked on 8.x, 9.x and 10.6.0 using
nvm
It looks like the config value is never used in
search.js
. Compare the other referenced commands from the help docs:ls.js
andhelp-search.js
. Both access the config viathis.npm.config.get('long')
, butsearch.js
only usesthis.npm.flatOptions
which doesn't contain thelong
prop.Environment
; nothing special
The text was updated successfully, but these errors were encountered: