spec: import asset as txt file, for bundlers

This commit is contained in:
2025-01-04 18:33:11 +08:00
parent ab8e6b57f9
commit abb60fe3cb
3 changed files with 6 additions and 2 deletions

4
assets/assets.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
declare module '*.cfg' {
const content: string;
export default content;
}

View File

@@ -30,6 +30,7 @@ async function buildFile(entryFile) {
'--platform=node', '--platform=node',
'--format=esm', '--format=esm',
'--minify', '--minify',
'--loader:.cfg=text',
'--outfile=' + outputFile, '--outfile=' + outputFile,
]; ];

View File

@@ -6,6 +6,7 @@ import { Readable, Writable } from 'stream';
import { createInterface } from 'readline'; import { createInterface } from 'readline';
import { projectRoot } from '../environment/index.js'; import { projectRoot } from '../environment/index.js';
import { SPECBenchData, benchpath, exepath, buildpath } from './benchData.js'; import { SPECBenchData, benchpath, exepath, buildpath } from './benchData.js';
import specTemplate from '../../assets/specTemplate.cfg';
@@ -56,8 +57,6 @@ export function mkBench(spec: SPEC, bench: SPECBenchData): Bench {
}; };
} }
const specTemplate = fs.readFileSync(path.resolve(projectRoot, "assets", "specTemplate.cfg")).toString("utf-8");
const writeFile = promisify(fs.writeFile); const writeFile = promisify(fs.writeFile);
export interface ConfigOptions { export interface ConfigOptions {