Skip to content

Commit

Permalink
added plugin status logging
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Aug 3, 2016
1 parent d4d64ed commit 51b7b1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/core/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ module.exports = Common;
*/
Common.log = function() {
if (console && Common.logLevel > 0 && Common.logLevel <= 3) {
console.log.apply(console, [Matter.name + ':'].concat(Array.prototype.slice.call(arguments)));
console.log.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments)));
}
};

Expand All @@ -335,7 +335,7 @@ module.exports = Common;
*/
Common.info = function() {
if (console && Common.logLevel > 0 && Common.logLevel <= 2) {
console.info.apply(console, [Matter.name + ':'].concat(Array.prototype.slice.call(arguments)));
console.info.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments)));
}
};

Expand All @@ -347,7 +347,7 @@ module.exports = Common;
*/
Common.warn = function() {
if (console && Common.logLevel > 0 && Common.logLevel <= 3) {
console.warn.apply(console, [Matter.name + ':'].concat(Array.prototype.slice.call(arguments)));
console.warn.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments)));
}
};

Expand Down
14 changes: 9 additions & 5 deletions src/core/Plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,33 +75,37 @@ var Common = require('./Common');
}

var dependencies = Plugin.trackDependencies(base),
sortedDependencies = Common.topologicalSort(dependencies);
sortedDependencies = Common.topologicalSort(dependencies),
status = [];

console.log(dependencies, sortedDependencies);

for (var i = 0; i < sortedDependencies.length; i += 1) {
if (sortedDependencies[i] === base.name) {
continue;
}

var plugin = Plugin.resolve(sortedDependencies[i]);

if (!plugin) {
status.push('❌ ' + sortedDependencies[i]);
}

if (!plugin || Plugin.isUsed(base, plugin.name)) {
continue;
}

if (!Plugin.isFor(plugin, base)) {
Common.log('Plugin.installDependencies: ' + Plugin.toString(plugin) + ' is for ' + plugin.for + ' but installed on ' + Plugin.toString(base) + '.', 'warn');
Common.warn('Plugin.installDependencies:', Plugin.toString(plugin), 'is for', plugin.for, 'but installed on', Plugin.toString(base) + '.');
}

if (plugin.install) {
plugin.install(base);
status.push('✅ ' + Plugin.toString(plugin));
}

base.used.push(plugin.name);
}

console.log(base.used);
Common.info('Plugin status:', status.join(', '));
};

Plugin.trackDependencies = function(base, tracked) {
Expand Down

0 comments on commit 51b7b1d

Please sign in to comment.