mirror of https://gitee.com/bigwinds/arangodb
Saner manifest handling.
Controllers and tests are coerced into an object/array on parse instead of on demand. Removed unnecessary function.
This commit is contained in:
parent
4e5d097f1a
commit
281fbf1fcb
|
@ -144,16 +144,23 @@ var manifestSchema = {
|
|||
})
|
||||
),
|
||||
scripts: (
|
||||
joi.object()
|
||||
joi.object().optional()
|
||||
.pattern(RE_EMPTY, joi.forbidden())
|
||||
.pattern(RE_NOT_EMPTY, joi.string().required())
|
||||
.default(function () {return {};}, 'empty scripts object')
|
||||
.default(Object, 'empty scripts object')
|
||||
),
|
||||
setup: joi.string().optional(), // TODO remove in 2.8
|
||||
teardown: joi.string().optional(), // TODO remove in 2.8
|
||||
tests: (
|
||||
joi.alternatives()
|
||||
.try(
|
||||
joi.string().required(),
|
||||
(
|
||||
joi.array().optional()
|
||||
.items(joi.string().required())
|
||||
.default(Array, 'empty test files array')
|
||||
)
|
||||
)
|
||||
),
|
||||
thumbnail: joi.string().optional(),
|
||||
version: joi.string().required(),
|
||||
|
@ -352,6 +359,14 @@ var checkManifest = function(filename, manifest) {
|
|||
}
|
||||
});
|
||||
|
||||
if (typeof manifest.controllers === 'string') {
|
||||
manifest.controllers = {'/': manifest.controllers};
|
||||
}
|
||||
|
||||
if (typeof manifest.tests === 'string') {
|
||||
manifest.tests = [manifest.tests];
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
throw new ArangoError({
|
||||
errorNum: errors.ERROR_INVALID_APPLICATION_MANIFEST.code,
|
||||
|
|
|
@ -634,9 +634,7 @@ function escapeHTML (string) {
|
|||
var controllers = app._manifest.controllers;
|
||||
|
||||
try {
|
||||
if (typeof controllers === "string") {
|
||||
mountController(app, routes, "/", controllers);
|
||||
} else if (controllers) {
|
||||
if (controllers) {
|
||||
Object.keys(controllers).forEach(function (key) {
|
||||
mountController(app, routes, key, controllers[key]);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue