1
1
2
- import { readFileSync , writeFileSync } from "node:fs" ;
2
+ import { readdirSync , readFileSync , writeFileSync } from "node:fs" ;
3
3
import { Biome , Distribution } from "@biomejs/js-api" ;
4
- import { config , createResultFilePath , errorFilePath , finalResultPath , formatterErrorFilePath , shouldTakeABreath , startFilePath } from "./config" ;
4
+ import { config , createResultFilePath , errorFilePath , finalResultPath , formatterErrorFilePath , resultsDirectory , resumeMode , shouldTakeABreath , startFilePath } from "./config" ;
5
5
import { VirtualTypeScriptEnvironment } from "@typescript/vfs" ;
6
6
import ts from "typescript" ;
7
7
import { inspect } from "node:util" ;
8
+ import { join } from "node:path" ;
8
9
9
10
export interface ProgramRun {
10
11
env : VirtualTypeScriptEnvironment ;
@@ -172,7 +173,8 @@ export const finalizeProgram = async ({
172
173
resultTypeName : string ;
173
174
env : VirtualTypeScriptEnvironment ;
174
175
} ) => {
175
- const relativeLastResult = createResultFilePath ( lastInstructionCount )
176
+ const absoluteLastResult = createResultFilePath ( lastInstructionCount )
177
+ const relativeLastResult = absoluteLastResult . replace ( resultsDirectory , "." ) ;
176
178
177
179
const readStringImportLine = config . readStringFromMemory
178
180
? [
@@ -252,4 +254,27 @@ export const printType = (typeString: string) => {
252
254
}
253
255
254
256
return output ;
255
- } ;
257
+ } ;
258
+
259
+ export const getStartFilePath = ( ) => {
260
+ if ( ! resumeMode ) {
261
+ return startFilePath ;
262
+ }
263
+
264
+ const files = readdirSync ( resultsDirectory ) ;
265
+
266
+ const resumeIndex = process . argv . indexOf ( "--resume" ) ;
267
+ const maybeResumeFile = process . argv [ resumeIndex + 1 ] ;
268
+ if ( maybeResumeFile ) {
269
+ if ( ! files . includes ( maybeResumeFile ) ) {
270
+ throw new Error ( `specified resume file '${ maybeResumeFile } ' not found in ${ resultsDirectory } ` ) ;
271
+ }
272
+ return join ( resultsDirectory , maybeResumeFile ) ;
273
+ }
274
+
275
+ const filenames = files . filter ( file => {
276
+ return file . startsWith ( "result-" ) && file . endsWith ( ".ts" ) ;
277
+ } ) . sort ( ) ;
278
+
279
+ return join ( resultsDirectory , filenames [ filenames . length - 1 ] ) ;
280
+ }
0 commit comments