UNPKG

e2ed

Version:

E2E testing framework over Playwright

32 lines (31 loc) 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runBeforePackFunctions = void 0; const generalLog_1 = require("../generalLog"); const object_1 = require("../object"); const userland_1 = require("../userland"); /** * Runs functions from `doBeforePack` pack config field. * @internal */ const runBeforePackFunctions = async (startInfo) => { const { fullPackConfig } = startInfo; const { doBeforePack: functions, ...fullPackConfigWithoutDoBeforePack } = fullPackConfig; (0, object_1.setReadonlyProperty)(startInfo, 'fullPackConfig', fullPackConfigWithoutDoBeforePack); const args = [startInfo]; const processCurrentFunctionResult = (result) => { if (result === undefined) { return; } (0, object_1.setReadonlyProperty)(startInfo, 'fullPackConfig', result); }; const functionNames = functions.map(({ name }) => name || 'anonymous').join(', '); const message = functions.length > 0 ? `Will be run ${functions.length} before pack function${functions.length > 1 ? 's' : ''} (${functionNames})` : 'There are no before pack functions'; (0, generalLog_1.generalLog)(message); const beforePackExecutionTimeWithUnits = await (0, userland_1.runArrayOfUserlandFunctions)(functions, () => args, processCurrentFunctionResult); (0, object_1.setReadonlyProperty)(startInfo, 'beforePackExecutionTimeWithUnits', beforePackExecutionTimeWithUnits); (0, object_1.setReadonlyProperty)(startInfo.fullPackConfig, 'doBeforePack', functions); }; exports.runBeforePackFunctions = runBeforePackFunctions;