Skip to content

Commit

Permalink
feat: add warning generator for missing deps
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 14, 2018
1 parent 864f67b commit f81481d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions addon/__dev__/warnOnMissingDependencies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

var pkg = require('../../package.json');

module.exports = function warnOnMissingDependencies (addon, renderer, deps) {
var missing = [];

for (var i = 0; i < deps.length; i++) {
var name = deps[i];

if (!renderer[name]) {
missing.push(name);
}
}

if (missing.length) {
var str = 'Addon "' + addon + '" is missing the following dependencies:';

for (var j = 0; j < missing.length; j++) {
str += '\n require("' + pkg.name + '/addon/' + missing[j] + '").addon(renderer);';
}

throw new Error(str);
}
};

0 comments on commit f81481d

Please sign in to comment.