31 lines
3.7 KiB
JavaScript
31 lines
3.7 KiB
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.processReporterName = exports.isReporterPluginFactory = exports.getPluginFactory = exports.requireReporterPluginFactory = void 0;
|
||
|
const runtime_1 = require("../errors/runtime");
|
||
|
const types_1 = require("../errors/types");
|
||
|
function requireReporterPluginFactory(reporterName) {
|
||
|
try {
|
||
|
return require('testcafe-reporter-' + reporterName);
|
||
|
}
|
||
|
catch (err) {
|
||
|
throw new runtime_1.GeneralError(types_1.RUNTIME_ERRORS.cannotFindReporterForAlias, reporterName);
|
||
|
}
|
||
|
}
|
||
|
exports.requireReporterPluginFactory = requireReporterPluginFactory;
|
||
|
function getPluginFactory(reporterFactorySource) {
|
||
|
if (!isReporterPluginFactory(reporterFactorySource))
|
||
|
return requireReporterPluginFactory(reporterFactorySource);
|
||
|
return reporterFactorySource;
|
||
|
}
|
||
|
exports.getPluginFactory = getPluginFactory;
|
||
|
function isReporterPluginFactory(value) {
|
||
|
return typeof value === 'function';
|
||
|
}
|
||
|
exports.isReporterPluginFactory = isReporterPluginFactory;
|
||
|
function processReporterName(value) {
|
||
|
if (isReporterPluginFactory(value))
|
||
|
return value.name || 'function () {}';
|
||
|
return value;
|
||
|
}
|
||
|
exports.processReporterName = processReporterName;
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVwb3J0ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvcmVwb3J0ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQ0EsK0NBQWlEO0FBQ2pELDJDQUFpRDtBQUVqRCxTQUFnQiw0QkFBNEIsQ0FBRSxZQUFvQjtJQUM5RCxJQUFJO1FBQ0EsT0FBTyxPQUFPLENBQUMsb0JBQW9CLEdBQUcsWUFBWSxDQUFDLENBQUM7S0FDdkQ7SU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