base/scripts/prepare-test-lib.js

23 lines
760 B
JavaScript
Raw Normal View History

import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const root = path.resolve(__dirname, '..');
const testLibDir = path.join(root, 'test', 'lib');
const copies = [
['../../state/dist/state.js', 'state.js'],
['../../bootstrap/dist/bootstrap.js', 'bootstrap.js'],
['../dist/base.js', 'base.js']
];
fs.mkdirSync(testLibDir, { recursive: true });
for (const [sourceRelPath, targetName] of copies) {
const source = path.resolve(__dirname, sourceRelPath);
const target = path.join(testLibDir, targetName);
if (!fs.existsSync(source)) throw new Error(`Missing test dependency: ${source}`);
fs.copyFileSync(source, target);
}