MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / getVariantBuildCommand

Function getVariantBuildCommand

dev-packages/e2e-tests/run.ts:81–116  ·  view source on GitHub ↗
(
  packageJsonPath: string,
  variantLabel: string,
  testAppPath: string,
)

Source from the content-addressed store, hash-verified

79}
80
81async function getVariantBuildCommand(
82 packageJsonPath: string,
83 variantLabel: string,
84 testAppPath: string,
85): Promise<{ buildCommand: string; assertCommand: string; testLabel: string; matchedVariantLabel?: string }> {
86 try {
87 const packageJsonContent = await readFile(packageJsonPath, 'utf-8');
88 const packageJson: PackageJson = JSON.parse(packageJsonContent);
89
90 const allVariants = [
91 ...(packageJson.sentryTest?.variants || []),
92 ...(packageJson.sentryTest?.optionalVariants || []),
93 ];
94
95 const matchingVariant = findMatchingVariant(allVariants, variantLabel);
96
97 if (matchingVariant) {
98 return {
99 buildCommand: matchingVariant['build-command'] || 'pnpm test:build',
100 assertCommand: matchingVariant['assert-command'] || 'pnpm test:assert',
101 testLabel: matchingVariant.label || testAppPath,
102 matchedVariantLabel: matchingVariant.label,
103 };
104 }
105
106 console.log(`No matching variant found for "${variantLabel}" in ${testAppPath}, using default build`);
107 } catch {
108 console.log(`Could not read variants from package.json for ${testAppPath}, using default build`);
109 }
110
111 return {
112 buildCommand: 'pnpm test:build',
113 assertCommand: 'pnpm test:assert',
114 testLabel: testAppPath,
115 };
116}
117
118async function run(): Promise<void> {
119 // Load environment variables from .env file locally

Callers 1

runFunction · 0.85

Calls 2

findMatchingVariantFunction · 0.85
logMethod · 0.65

Tested by

no test coverage detected