Merge pull request #16508 from strapi/chore/add-error-on-empty-content-type-folder

This commit is contained in:
Ben Irvin 2023-04-27 14:22:54 +02:00 committed by GitHub
commit c33855d39e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ const { existsSync } = require('fs-extra');
const _ = require('lodash');
const fse = require('fs-extra');
const { isKebabCase, importDefault } = require('@strapi/utils');
const { isEmpty } = require('lodash/fp');
const DEFAULT_CONTENT_TYPE = {
schema: {},
@ -115,6 +116,10 @@ const loadContentTypes = async (dir) => {
const contentTypeName = normalizeName(fd.name);
const contentType = await loadDir(join(dir, fd.name));
if (isEmpty(contentType) || isEmpty(contentType.schema)) {
throw new Error(`Could not load content type found at ${dir}`);
}
contentTypes[normalizeName(contentTypeName)] = _.defaults(contentType, DEFAULT_CONTENT_TYPE);
}