Skip to content

Commit c018637

Browse files
author
Nuno Nogueira
committed
added flags option to precompile
1 parent 72c3400 commit c018637

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/core/precompile.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export async function precompile(
1414
includes: string[],
1515
excludes: string[],
1616
testcases: string[] | undefined,
17+
flags: string,
1718
transformFunction = join(projectRoot, "transform", "listFunctions.mjs")
1819
): Promise<UnittestPackage> {
1920
// if specify testcases, use testcases for unittest
@@ -23,7 +24,7 @@ export async function precompile(
2324
const sourceCodePaths = getRelatedFiles(includes, excludes, (path: string) => !path.endsWith(".test.ts"));
2425
const sourceCodeTransforms: Promise<void>[] = [];
2526
for (const sourceCodePath of sourceCodePaths.values()) {
26-
sourceCodeTransforms.push(transform(sourceCodePath, transformFunction));
27+
sourceCodeTransforms.push(transform(sourceCodePath, transformFunction, flags));
2728
}
2829
await Promise.all(sourceCodeTransforms);
2930

@@ -55,15 +56,20 @@ export function getRelatedFiles(includes: string[], excludes: string[], filter:
5556
return result;
5657
}
5758

58-
async function transform(sourceCodePath: string, transformFunction: string) {
59-
const { error, stderr } = await main([
60-
sourceCodePath,
61-
"--noEmit",
62-
"--disableWarning",
63-
"--transform",
64-
transformFunction,
65-
"-O0",
66-
]);
59+
async function transform(sourceCodePath: string, transformFunction: string, flags: string) {
60+
let ascArgv = [
61+
sourceCodePath,
62+
"--noEmit",
63+
"--disableWarning",
64+
"--transform",
65+
transformFunction,
66+
"-O0",
67+
]
68+
if (flags) {
69+
const argv = flags.split(" ");
70+
ascArgv = ascArgv.concat(argv);
71+
}
72+
const { error, stderr } = await main(ascArgv);
6773
if (error) {
6874
// eslint-disable-next-line @typescript-eslint/no-base-to-string
6975
console.error(stderr.toString());

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export type OutputMode = "html" | "json" | "table";
7575
export async function start_unit_test(fo: FileOption, to: TestOption, oo: OutputOption): Promise<boolean> {
7676
emptydirSync(oo.outputFolder);
7777
emptydirSync(oo.tempFolder);
78-
const unittestPackage = await precompile(fo.includes, fo.excludes, fo.testcases);
78+
const unittestPackage = await precompile(fo.includes, fo.excludes, fo.testcases, to.flags);
7979
console.log(chalk.blueBright("code analysis: ") + chalk.bold.greenBright("OK"));
8080
const wasmPaths = await compile(unittestPackage.testCodePaths, oo.tempFolder, to.flags);
8181
console.log(chalk.blueBright("compile testcases: ") + chalk.bold.greenBright("OK"));

0 commit comments

Comments
 (0)