Skip to content

Commit

Permalink
fix: dont throw for /^meta-/ packages with no "register" function (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson authored and mateodelnorte committed Dec 21, 2018
1 parent 8ad994f commit 42f43e7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/registerPlugin.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
const { green, yellow } = require('chalk');
const { gray, green, red, yellow } = require('chalk');
const debug = require('debug')('meta');
const path = require('path');
const tildify = require('tildify');

module.exports = (program, pluginPath) => {
try {
debug(` ${green('+')} ${path.basename(pluginPath)} ${yellow(tildify(pluginPath))}`); // prettier-ignore
require(pluginPath).register(program);
const plugin = require(pluginPath);
if (plugin.register) {
plugin.register(program);
debug(` ${green('+')} ${path.basename(pluginPath)} ${yellow(tildify(pluginPath))}`); // prettier-ignore
} else {
debug(` ${red('×')} ${path.basename(pluginPath)} ${gray('(not a plugin)')}`); // prettier-ignore
}
} catch (e) {
console.warn(`Plugin registration failed: '${tildify(pluginPath)}'`);
console.error(e);
Expand Down

0 comments on commit 42f43e7

Please sign in to comment.