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: (
|
scripts: (
|
||||||
joi.object()
|
joi.object().optional()
|
||||||
.pattern(RE_EMPTY, joi.forbidden())
|
.pattern(RE_EMPTY, joi.forbidden())
|
||||||
.pattern(RE_NOT_EMPTY, joi.string().required())
|
.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
|
setup: joi.string().optional(), // TODO remove in 2.8
|
||||||
teardown: joi.string().optional(), // TODO remove in 2.8
|
teardown: joi.string().optional(), // TODO remove in 2.8
|
||||||
tests: (
|
tests: (
|
||||||
joi.array().optional()
|
joi.alternatives()
|
||||||
.items(joi.string().required())
|
.try(
|
||||||
|
joi.string().required(),
|
||||||
|
(
|
||||||
|
joi.array().optional()
|
||||||
|
.items(joi.string().required())
|
||||||
|
.default(Array, 'empty test files array')
|
||||||
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
thumbnail: joi.string().optional(),
|
thumbnail: joi.string().optional(),
|
||||||
version: joi.string().required(),
|
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) {
|
if (!valid) {
|
||||||
throw new ArangoError({
|
throw new ArangoError({
|
||||||
errorNum: errors.ERROR_INVALID_APPLICATION_MANIFEST.code,
|
errorNum: errors.ERROR_INVALID_APPLICATION_MANIFEST.code,
|
||||||
|
|
|
@ -634,9 +634,7 @@ function escapeHTML (string) {
|
||||||
var controllers = app._manifest.controllers;
|
var controllers = app._manifest.controllers;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (typeof controllers === "string") {
|
if (controllers) {
|
||||||
mountController(app, routes, "/", controllers);
|
|
||||||
} else if (controllers) {
|
|
||||||
Object.keys(controllers).forEach(function (key) {
|
Object.keys(controllers).forEach(function (key) {
|
||||||
mountController(app, routes, key, controllers[key]);
|
mountController(app, routes, key, controllers[key]);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue