Skip to content

Commit

Permalink
Encapsulate.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkambic committed Feb 12, 2024
1 parent 438e571 commit d0f96d9
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions x-pack/plugins/synthetics/server/common/mem_writable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ export class MemWritable extends Writable {
}
}

function wrapInlineInProject(inlineJourney: string) {
return `import { journey, step, expect } from '@elastic/synthetics';
journey('inline', ({ page, context, browser, params, request }) => {
${inlineJourney}
});
`;
}

export async function inlineToProjectZip(
inlineJourney: string,
monitorId: string,
Expand All @@ -48,17 +57,9 @@ export async function inlineToProjectZip(
archive.on('error', reject);
mWriter.on('close', resolve);
archive.pipe(mWriter);
archive.append(
`import { journey, step, expect } from '@elastic/synthetics';
journey('inline', ({ page, context, browser, params, request }) => {
${inlineJourney}
});
`,
{
name: 'inline.journey.ts',
}
);
archive.append(wrapInlineInProject(inlineJourney), {
name: 'inline.journey.ts',
});
archive.finalize();
});
} catch (e) {
Expand Down

0 comments on commit d0f96d9

Please sign in to comment.