Skip to content

Commit 77bc43f

Browse files
committed
suppress syntax error logging in tests
1 parent 7223f9f commit 77bc43f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/javascript.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ export interface ParseOptions {
5050
inline?: boolean;
5151
sourceLine?: number;
5252
globals?: Set<string>;
53+
verbose?: boolean;
5354
}
5455

5556
export function transpileJavaScript(input: string, options: ParseOptions): Transpile {
56-
const {id, root, sourcePath} = options;
57+
const {id, root, sourcePath, verbose = true} = options;
5758
try {
5859
const node = parseJavaScript(input, options);
5960
const databases = node.features
@@ -97,7 +98,7 @@ ${String(output)}${node.declarations?.length ? `\nreturn {${node.declarations.ma
9798
}
9899
// TODO: Consider showing a code snippet along with the error. Also, consider
99100
// whether we want to show the file name here.
100-
console.error(`${error.name}: ${message}`);
101+
if (verbose) console.error(`${error.name}: ${message}`);
101102
return {
102103
id: `${id}`,
103104
body: `() => { throw new SyntaxError(${JSON.stringify(error.message)}); }`

test/javascript-test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ function runTests({
3434
await transpileJavaScript(await readFile(path, "utf8"), {
3535
id: "0",
3636
root: inputRoot,
37-
sourcePath: name
37+
sourcePath: name,
38+
verbose: false
3839
})
3940
);
4041
let expected;

0 commit comments

Comments
 (0)