Skip to content

Commit

Permalink
feat(plugin): checkInstall w/ warning msg
Browse files Browse the repository at this point in the history
  • Loading branch information
mlynch committed Sep 25, 2016
1 parent 1b87af8 commit 47112c7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getPlugin = function(pluginRef: string): any {
* @param pluginObj
* @param method
*/
export const pluginWarn = function(pluginObj: any, method: string) {
export const pluginWarn = function(pluginObj: any, method?: string) {
let pluginName = pluginObj.name, plugin = pluginObj.plugin;
if (method) {
console.warn('Native: tried calling ' + pluginName + '.' + method + ', but the ' + pluginName + ' plugin is not installed.');
Expand Down Expand Up @@ -322,14 +322,24 @@ export function Plugin(config) {
cls[k] = config[k];
}

cls['installed'] = function() {
cls['installed'] = function(printWarning?: boolean) {
return !!getPlugin(config.pluginRef);
};

cls['getPlugin'] = function() {
return getPlugin(config.pluginRef);
};

cls['checkInstall'] = function() {
let pluginInstance = getPlugin(config.pluginRef);

if (!pluginInstance) {
pluginWarn(cls);
return false;
}
return true;
};

return cls;
};
}
Expand Down

0 comments on commit 47112c7

Please sign in to comment.