@@ -11,7 +11,7 @@ import {
1111 type SourceFile ,
1212 SyntaxKind ,
1313} from "@typescript/ast" ;
14- import fs from "node:fs" ;
14+ import fs , { existsSync } from "node:fs" ;
1515import path from "node:path" ;
1616import { fileURLToPath } from "node:url" ;
1717import { Bench } from "tinybench" ;
@@ -23,6 +23,12 @@ if (isMain) {
2323}
2424
2525export async function runBenchmarks ( singleIteration ?: boolean ) {
26+ const repoRoot = fileURLToPath ( new URL ( "../../../" , import . meta. url ) . toString ( ) ) ;
27+ if ( ! existsSync ( path . join ( repoRoot , "_submodules/TypeScript/src/compiler" ) ) ) {
28+ console . warn ( "Warning: TypeScript submodule is not cloned; skipping benchmarks." ) ;
29+ return ;
30+ }
31+
2632 const bench = new Bench ( {
2733 name : "Sync API" ,
2834 teardown,
@@ -163,14 +169,14 @@ export async function runBenchmarks(singleIteration?: boolean) {
163169
164170 function spawnAPI ( ) {
165171 api = new API ( {
166- cwd : fileURLToPath ( new URL ( "../../../" , import . meta . url ) . toString ( ) ) ,
172+ cwd : repoRoot ,
167173 tsserverPath : fileURLToPath ( new URL ( `../../../built/local/tsgo${ process . platform === "win32" ? ".exe" : "" } ` , import . meta. url ) . toString ( ) ) ,
168174 } ) ;
169175 }
170176
171177 function spawnAPIHosted ( ) {
172178 api = new API ( {
173- cwd : fileURLToPath ( new URL ( "../../../" , import . meta . url ) . toString ( ) ) ,
179+ cwd : repoRoot ,
174180 tsserverPath : fileURLToPath ( new URL ( `../../../built/local/tsgo${ process . platform === "win32" ? ".exe" : "" } ` , import . meta. url ) . toString ( ) ) ,
175181 fs : createNodeFileSystem ( ) ,
176182 } ) ;
0 commit comments