mirror of
https://github.com/appium/appium.git
synced 2026-10-25 02:00:57 +08:00
also ensure that each session gets its own plugin instances so plugins for different sessions can't share state
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
import _ from 'lodash';
|
|
import ExtensionConfig, { PLUGIN_TYPE } from './extension-config';
|
|
import log from './logger';
|
|
|
|
export default class PluginConfig extends ExtensionConfig {
|
|
constructor (appiumHome, logFn = null) {
|
|
super(appiumHome, PLUGIN_TYPE, logFn);
|
|
}
|
|
|
|
extensionDesc (pluginName, {version}) {
|
|
return `${pluginName}@${version}`;
|
|
}
|
|
|
|
print (activeNames) {
|
|
const pluginNames = Object.keys(this.installedExtensions);
|
|
|
|
if (_.isEmpty(pluginNames)) {
|
|
log.info(`No plugins have been installed. Use the "appium plugin" ` +
|
|
'command to install the one(s) you want to use.');
|
|
return;
|
|
}
|
|
|
|
log.info(`Available plugins:`);
|
|
for (const [pluginName, pluginData] of _.toPairs(this.installedExtensions)) {
|
|
const activeTxt = _.includes(activeNames, pluginName) ? ' (ACTIVE)' : '';
|
|
log.info(` - ${this.extensionDesc(pluginName, pluginData)}${activeTxt}`);
|
|
}
|
|
|
|
if (_.isEmpty(activeNames)) {
|
|
log.info('No plugins activated. Use the --plugins flag with names of plugins to activate');
|
|
}
|
|
}
|
|
}
|