widget-loader
Advanced tools
Comparing version 0.3.0 to 1.0.0
@@ -1,3 +0,3 @@ | ||
"use strict" | ||
// load main lib | ||
module.exports = require('./lib/loader'); | ||
module.exports = require('./lib/loader'); |
"use strict"; | ||
const _ = require('lodash'); | ||
const sequence = require('when/sequence'); | ||
const path = require('path'); | ||
@@ -11,4 +9,2 @@ const fs = require('fs'); | ||
module.exports = function (App, opts) { | ||
@@ -34,3 +30,3 @@ | ||
// Check for an actual class, catch just use whatever was returned | ||
if (_.isFunction(AppClass)) { | ||
if (typeof AppClass === 'function') { | ||
app = new AppClass(); | ||
@@ -116,5 +112,5 @@ } else { | ||
function sortWidgets (widgetCollection) { | ||
let widgetPositions = _.keys(widgetCollection); | ||
let widgetPositions = Object.keys(widgetCollection); | ||
_.each(widgetPositions, function (key) { | ||
widgetPositions.forEach(function (key) { | ||
widgetCollection[key].sort(function (obj1, obj2) { | ||
@@ -142,3 +138,3 @@ return obj1.config.order - obj2.config.order; | ||
// filter and get widgets for only this specific page | ||
filteredWidgets = _.filter(WidgetCollection, function (widget) { | ||
filteredWidgets = WidgetCollection.filter(function (widget) { | ||
return widget.config.active && matchRoute(widget.config.routes, req.path); | ||
@@ -148,3 +144,3 @@ }); | ||
// execute widget request and extract return data | ||
widgetOps = _.map(filteredWidgets, function (widget) { | ||
widgetOps = filteredWidgets.map(function (widget) { | ||
return function () { | ||
@@ -165,3 +161,3 @@ return widget.exec(App) | ||
if (!_.isArray(CurrentWidgetCollection[position])) { | ||
if (!Array.isArray(CurrentWidgetCollection[position])) { | ||
CurrentWidgetCollection[position] = []; | ||
@@ -182,3 +178,3 @@ } | ||
// when widgets are loaded, continue | ||
sequence(widgetOps) | ||
Promise.all(widgetOps) | ||
.then(function () { | ||
@@ -185,0 +181,0 @@ //console.timeEnd('middlware'); |
{ | ||
"name": "widget-loader", | ||
"version": "0.3.0", | ||
"version": "1.0.0", | ||
"description": "Widget loader for WidGet CMS", | ||
@@ -28,5 +28,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"ghost-sandbox": "^0.1.1", | ||
"lodash": "^4.13.1", | ||
"when": "^3.7.3" | ||
"ghost-sandbox": "^1.0.0" | ||
}, | ||
@@ -33,0 +31,0 @@ "devDependencies": { |
"use strict"; | ||
const config = require('./config.json'); | ||
const when = require('when'); | ||
@@ -9,3 +8,3 @@ module.exports.config = config; | ||
module.exports.exec = function (App) { | ||
return when(null); | ||
return Promise.resolve(null); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
0
9529
194
+ Addedghost-sandbox@1.0.1(transitive)
- Removedlodash@^4.13.1
- Removedwhen@^3.7.3
- Removedghost-sandbox@0.1.1(transitive)
- Removedlodash@3.10.14.17.21(transitive)
- Removedwhen@3.7.8(transitive)
Updatedghost-sandbox@^1.0.0