MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / isCloudflarePages

Function isCloudflarePages

packages/astro/src/integration/index.ts:269–295  ·  view source on GitHub ↗

* Detects if the project is a Cloudflare Pages project by checking for * `pages_build_output_dir` in the wrangler configuration file. * * Cloudflare Pages projects use `pages_build_output_dir` while Workers projects * use `assets.directory` or `main` fields instead.

()

Source from the content-addressed store, hash-verified

267 * use `assets.directory` or `main` fields instead.
268 */
269function isCloudflarePages(): boolean {
270 const cwd = process.cwd();
271 const configFiles = ['wrangler.jsonc', 'wrangler.json', 'wrangler.toml'];
272
273 for (const configFile of configFiles) {
274 const configPath = path.join(cwd, configFile);
275
276 if (!fs.existsSync(configPath)) {
277 continue;
278 }
279
280 const content = fs.readFileSync(configPath, 'utf-8');
281
282 if (configFile.endsWith('.toml')) {
283 // https://regex101.com/r/Uxe4p0/1
284 // Match pages_build_output_dir as a TOML key (at start of line, ignoring whitespace)
285 // This avoids false positives from comments (lines starting with #)
286 return /^\s*pages_build_output_dir\s*=/m.test(content);
287 }
288
289 // Match "pages_build_output_dir" as a JSON key (followed by :)
290 // This works for both .json and .jsonc without needing to strip comments
291 return /"pages_build_output_dir"\s*:/.test(content);
292 }
293
294 return false;
295}
296
297function getSourcemapsAssetsGlob(config: AstroConfig): string {
298 // The vercel adapter puts the output into its .vercel directory

Callers 1

sentryAstroFunction · 0.85

Calls 1

testMethod · 0.65

Tested by

no test coverage detected