30 lines
937 B
JavaScript
Raw Permalink Normal View History

#!/usr/bin/env node
/**
* @open-matrix/contracts build
*
* Type contracts + one pure runtime function (decideMatrixPlacementBind).
* Emits .js + .d.ts via tsc. Part of core-decontamination Phase 2.
*/
import { execFileSync } from 'node:child_process';
import { createRequire } from 'node:module';
import { rmSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const distDir = resolve(__dirname, 'dist');
const require = createRequire(import.meta.url);
const typescriptPackageJson = require.resolve('typescript/package.json', { paths: [__dirname] });
const tscBin = resolve(dirname(typescriptPackageJson), 'bin/tsc');
rmSync(distDir, { recursive: true, force: true });
execFileSync(process.execPath, [
tscBin,
'-p',
resolve(__dirname, 'tsconfig.build.json'),
], {
cwd: __dirname,
stdio: 'inherit',
});