Something went wrong. Try again.
[PRE-ALPHA] an open source web-based 2D/3D graphing calculator cartesium.org
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243import { execFileSync } from 'node:child_process';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';
const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
type GitCommitReader = () => string;
export type BuildChannel = 'dev' | 'production';
function readGitCommit(): string { return execFileSync('git', ['rev-parse', 'HEAD'], { cwd: repositoryRoot, encoding: 'utf8' }).trim();}
export function resolveBuildCommit( env: NodeJS.ProcessEnv = process.env, readCommit: GitCommitReader = readGitCommit): string { const override = env.CARTESIUM_COMMIT?.trim();
if (override) return override;
try { const commit = readCommit().trim();
return commit || 'unknown'; } catch { return 'unknown'; }}
/** * Keep the development-server marker separate from the commit value. The * commit is also emitted as raw metadata, so adding a suffix to it would make * the full-commit tooltip and data attribute unusable for provenance checks. */export function resolveBuildChannel(command: 'build' | 'serve'): BuildChannel { return command === 'serve' ? 'dev' : 'production';}