File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 11import { getTelemetryFor } from 'ember-codemods-telemetry-helpers' ;
22import path from 'path' ;
33import { z } from 'zod' ;
4+ import logger from './log-helper' ;
45
56const RuntimeDataSchema = z . object ( {
67 type : z . string ( ) . optional ( ) ,
@@ -14,12 +15,19 @@ const RuntimeDataSchema = z.object({
1415export type RuntimeData = z . infer < typeof RuntimeDataSchema > ;
1516
1617/**
17- * TODO
18+ * Gets telemetry data for the file and parses it into a valid `RuntimeData`
19+ * object.
1820 */
1921export function getRuntimeData ( filePath : string ) : RuntimeData {
20- const rawTelemetry = getTelemetryFor ( path . resolve ( filePath ) ) ;
22+ let rawTelemetry = getTelemetryFor ( path . resolve ( filePath ) ) ;
2123 if ( ! rawTelemetry ) {
22- throw new RuntimeDataError ( 'Could not find runtime data' ) ;
24+ // Do not re-throw. The most likely reason this happened was because
25+ // the user's app threw an error. We still want the codemod to work if so.
26+ logger . error ( {
27+ filePath,
28+ error : new RuntimeDataError ( 'Could not find runtime data' ) ,
29+ } ) ;
30+ rawTelemetry = { } ;
2331 }
2432
2533 const result = RuntimeDataSchema . safeParse ( rawTelemetry ) ;
You can’t perform that action at this time.
0 commit comments