-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Adds ability to list installed plugins from CLI #5920
Changes from 2 commits
8fda0f9
0e14e41
ea0f2ef
d09f83b
2e9f00f
5bfccda
42334e3
cac0f06
ff15794
220fc8b
b9a8098
cbc3350
f8ba6ca
13c0ccc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const fs = require('fs'); | ||
|
||
module.exports = { | ||
list: list | ||
}; | ||
|
||
function list(settings, logger) { | ||
fs.readdir(settings.pluginDir, function (err, files) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For cli stuff like this, it's generally best to use the const files = fs.readdirSync(settings.pluginDir);
// ... |
||
|
||
var pluginFiles = files.filter(function (file) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We generally don't want to use Another option is to skip a new variable entirely and just chain your files
.filter(function (file) {
// ...
})
.forEach(function (pluginFile) {
// ...
}); |
||
return file[0] !== '.'; | ||
}); | ||
|
||
pluginFiles.forEach(function (pluginFile) { | ||
logger.log(pluginFile); | ||
}); | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,8 +84,12 @@ export default function createSettingParser(options) { | |
settings.package = parts.shift(); | ||
} | ||
|
||
if (!settings.action || (options.install && options.remove)) { | ||
throw new Error('Please specify either --install or --remove.'); | ||
if (options.list) { | ||
settings.action = 'list'; | ||
} | ||
|
||
if (!settings.action || (options.install && options.remove && options.list)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this conditional needs to get a bit more robust. It seems to be verifying that the user isn't trying to specify conflicting commands, which can be represented with a single conditional when there are only two possibilities. Now that there are three possibilities, I assume we want to verify that the user isn't trying to perform any combination of those commands, which will take more than a simple conditional to verify. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I wasn't quite clear on the original intent here but what you say seems right. Will fix. Thanks! |
||
throw new Error('Please specify either --install, --remove, or --list.'); | ||
} | ||
|
||
settings.pluginDir = options.pluginDir; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use an es6 export instead of commonjs, so:
instead of
module.exports = {...}
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, will make this change in this file. Should I also make the same change in the other
plugin_*.js
files in this directory (that aren't in the scope of this PR)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to modify the other files. We plan to run through the entire codebase before Kibana 5 to update the majority of the existing commonjs module stuff.