refactor: plural

This commit is contained in:
cha0s 2021-01-24 09:51:45 -06:00
parent ad4709aabe
commit dca45c052f
3 changed files with 7 additions and 2 deletions

View File

@ -23,6 +23,7 @@
"@latus/core": "^2.0.0", "@latus/core": "^2.0.0",
"debug": "4.3.1", "debug": "4.3.1",
"glob": "^7.1.6", "glob": "^7.1.6",
"lodash.flatten": "^4.4.0",
"natsort": "^2.0.2" "natsort": "^2.0.2"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,3 +1,5 @@
import flatten from 'lodash.flatten';
import {projects, user} from './state'; import {projects, user} from './state';
export * from './state'; export * from './state';
@ -8,7 +10,7 @@ export default {
'resource-renderers': [], 'resource-renderers': [],
}), }),
'@latus/core/starting': async (latus) => { '@latus/core/starting': async (latus) => {
const Renderers = await latus.invokeOrdered('@persea/core/resource-renderers'); const Renderers = flatten(await latus.invokeOrdered('@persea/core/resource-renderers'));
const Renderer = (uri) => { const Renderer = (uri) => {
const R = Renderers.find(({matcher}) => uri.match(matcher)); const R = Renderers.find(({matcher}) => uri.match(matcher));
return R ? R.Component : ({buffer}) => buffer.toString(); return R ? R.Component : ({buffer}) => buffer.toString();

View File

@ -22,6 +22,8 @@ export default {
draft.projects.resources[`${project}${uri}`] = JSONB.bufferify(json).toString('base64'); draft.projects.resources[`${project}${uri}`] = JSONB.bufferify(json).toString('base64');
}); });
}, },
'@persea/core/resource-renderers': () => JsonResourceComponent, '@persea/core/resource-renderers': () => [
JsonResourceComponent,
],
}, },
}; };