hades-cli
Version:
Hades CLI developer tool
22 lines (21 loc) • 923 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const handlebars = require("handlebars");
const common_functions_1 = require("./common-functions");
const sql_type_1 = require("../../types/sql-type");
const _ = require("lodash");
handlebars.registerHelper('fakerProperty', function (property, ...options) {
const params = common_functions_1.getFakerHelperParams(options, property);
// check viability of faker property
if (!!property.faker) {
const mock = common_functions_1.fakerHelper(property.faker, params);
if (!!mock)
return mock;
}
// check special types
if (property.type === sql_type_1.SqlType.RELATIONSHIP)
return '[]';
if (property.type === sql_type_1.SqlType.ENUM)
return property.enumOptions ? _.shuffle(property.enumOptions)[0] : null;
return common_functions_1.fakerByPropertyType(property, params);
});