Skip to content

Commit

Permalink
Merge pull request #406 from saplingjs/dependabot/npm_and_yarn/xo-0.48.0
Browse files Browse the repository at this point in the history
Bump xo from 0.46.4 to 0.48.0
  • Loading branch information
groenroos authored Feb 19, 2022
2 parents d43e896 + b8473bc commit 6ceef8e
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 229 deletions.
32 changes: 22 additions & 10 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,51 +43,63 @@ class App {

/* Load everything */
async.series([
async callback => await (await import('./core/loadConfig.js')).default.call(this, callback),
async callback => {
const { default: loadConfig } = await import('./core/loadConfig.js');
await loadConfig.call(this, callback);
},
async callback => {
if (options.loadServer !== false) {
await (await import('./core/loadServer.js')).default.call(this, options, callback);
const { default: loadServer } = await import('./core/loadServer.js');
await loadServer.call(this, options, callback);
}
},
async callback => {
if (options.loadModel !== false) {
await (await import('./core/loadModel.js')).default.call(this, callback);
const { default: loadModel } = await import('./core/loadModel.js');
await loadModel.call(this, callback);
}
},
async callback => {
if (options.loadPermissions !== false) {
await (await import('./core/loadPermissions.js')).default.call(this, callback);
const { default: loadPermissions } = await import('./core/loadPermissions.js');
await loadPermissions.call(this, callback);
}
},
async callback => {
if (options.loadController !== false) {
await (await import('./core/loadController.js')).default.call(this, callback);
const { default: loadController } = await import('./core/loadController.js');
await loadController.call(this, callback);
}
},
async callback => {
if (options.loadHooks !== false) {
await (await import('./core/loadHooks.js')).default.call(this, callback);
const { default: loadHooks } = await import('./core/loadHooks.js');
await loadHooks.call(this, callback);
}
},
async callback => {
if (options.loadViews !== false) {
await (await import('./core/loadCustomTags.js')).default.call(this, callback);
const { default: loadCustomTags } = await import('./core/loadCustomTags.js');
await loadCustomTags.call(this, callback);
}
},
async callback => {
await (await import('./core/loadModules.js')).default.call(this, callback);
const { default: loadModules } = await import('./core/loadModules.js');
await loadModules.call(this, callback);
},
async callback => {
if (options.loadViews !== false) {
for (const route in this.controller) {
if (Object.prototype.hasOwnProperty.call(this.controller, route)) {
await (await import('./core/initRoute.js')).default.call(this, route, this.controller[route]);
const { default: initRoute } = await import('./core/initRoute.js');
await initRoute.call(this, route, this.controller[route]);
}
}
}

if (options.loadREST !== false) {
await (await import('./core/loadRest.js')).default.call(this, callback);
const { default: loadRest } = await import('./core/loadRest.js');
await loadRest.call(this, callback);
}
},
callback => {
Expand Down
3 changes: 2 additions & 1 deletion core/loadHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export async function digest() {
/* Set exported functions as object values */
for (const hook of Object.keys(hooks)) {
const { method, route } = this.parseMethodRouteKey(hook);
formattedHooks[`${method} ${route}`] = (await import(path.join(this.dir, this.config.hooksDir, hooks[hook]))).default;
const { default: hookMethod } = await import(path.join(this.dir, this.config.hooksDir, hooks[hook]));
formattedHooks[`${method} ${route}`] = hookMethod;
}
}

Expand Down
12 changes: 6 additions & 6 deletions lib/Storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ export default class Storage {
const driver = String(this.app.config.db.driver).toLowerCase();

if (driver === 'memory') {
/* eslint-disable-next-line new-cap */
this.db = new (await import('../drivers/db/Memory.js')).default(this.options);
const { default: Memory } = await import('../drivers/db/Memory.js');
this.db = new Memory(this.options);
} else {
try {
/* eslint-disable-next-line new-cap */
this.db = new (await import(`@sapling/db-driver-${driver}`)).default(this.options);
const { default: Driver } = await import(`@sapling/db-driver-${driver}`);
this.db = new Driver(this.options);
} catch {
try {
/* eslint-disable-next-line new-cap */
this.db = new (await import(driver)).default(this.options);
const { default: Custom } = await import(driver);
this.db = new Custom(this.options);
} catch {
throw new SaplingError(`Cannot find any DB driver for '${driver}'`);
}
Expand Down
12 changes: 6 additions & 6 deletions lib/Templating.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ export default class Templating {
const driver = String(this.app.config.render.driver).toLowerCase();

if (driver === 'html') {
/* eslint-disable-next-line new-cap */
this.renderer = new (await import('../drivers/render/Html.js')).default(this.app, this.viewsPath);
const { default: Html } = await import('../drivers/render/Html.js');
this.renderer = new Html(this.app, this.viewsPath);
} else {
try {
/* eslint-disable-next-line new-cap */
this.renderer = new (await import(`@sapling/render-driver-${driver}`)).default(this.app, this.viewsPath);
const { default: Driver } = await import(`@sapling/render-driver-${driver}`);
this.renderer = new Driver(this.app, this.viewsPath);
} catch {
try {
/* eslint-disable-next-line new-cap */
this.renderer = new (await import(driver)).default(this.app, this.viewsPath);
const { default: Custom } = await import(driver);
this.renderer = new Custom(this.app, this.viewsPath);
} catch {
throw new SaplingError(`Cannot find any render driver for '${driver}'`);
}
Expand Down
Loading

0 comments on commit 6ceef8e

Please sign in to comment.