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 1
1
import { getTelemetryFor } from 'ember-codemods-telemetry-helpers' ;
2
2
import path from 'path' ;
3
3
import { z } from 'zod' ;
4
+ import logger from './log-helper' ;
4
5
5
6
const RuntimeDataSchema = z . object ( {
6
7
type : z . string ( ) . optional ( ) ,
@@ -14,12 +15,19 @@ const RuntimeDataSchema = z.object({
14
15
export type RuntimeData = z . infer < typeof RuntimeDataSchema > ;
15
16
16
17
/**
17
- * TODO
18
+ * Gets telemetry data for the file and parses it into a valid `RuntimeData`
19
+ * object.
18
20
*/
19
21
export function getRuntimeData ( filePath : string ) : RuntimeData {
20
- const rawTelemetry = getTelemetryFor ( path . resolve ( filePath ) ) ;
22
+ let rawTelemetry = getTelemetryFor ( path . resolve ( filePath ) ) ;
21
23
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 = { } ;
23
31
}
24
32
25
33
const result = RuntimeDataSchema . safeParse ( rawTelemetry ) ;
You can’t perform that action at this time.
0 commit comments