@@ -9,37 +9,31 @@ const [, , packagerPath, composedPath] = argv;
99
1010const TAG = '[@datadog/mobile-react-native]' ;
1111
12- const warn = message => {
13- console . warn ( `${ TAG } ${ message } ` ) ;
14- } ;
15-
16- const error = ( message , fatal = true ) => {
17- warn ( message ) ;
18- if ( fatal ) {
19- exit ( 1 ) ;
20- }
12+ const warnAndExit = message => {
13+ console . log ( `\n${ TAG } WARNING: ${ message } \n` ) ;
14+ exit ( 0 ) ;
2115} ;
2216
2317const safeLoad = path => {
2418 if ( ! path || ! existsSync ( path ) ) {
25- error ( `Debug ID copy failed: Missing or invalid file at ${ path } ` ) ;
19+ warnAndExit ( `Debug ID copy failed: Missing or invalid file at ${ path } ` ) ;
2620 }
2721 try {
2822 return JSON . parse ( readFileSync ( path , 'utf8' ) ) ;
2923 } catch {
30- error ( `Debug ID copy failed: Cannot parse JSON at ${ path } ` ) ;
24+ warnAndExit ( `Debug ID copy failed: Cannot parse JSON at ${ path } ` ) ;
3125 }
3226} ;
3327
3428const packagerMap = safeLoad ( packagerPath ) ;
3529const composedMap = safeLoad ( composedPath ) ;
3630
3731if ( ! packagerMap ?. debugId ) {
38- error ( 'No debugId found in packager sourcemap.' ) ;
32+ warnAndExit ( 'No debugId found in packager sourcemap.' ) ;
3933}
4034
4135if ( composedMap ?. debugId ) {
42- error ( 'Composed sourcemap already contains a debugId.' ) ;
36+ warnAndExit ( 'Composed sourcemap already contains a debugId.' ) ;
4337}
4438
4539composedMap . debugId = packagerMap . debugId ;
4842 writeFileSync ( composedPath , JSON . stringify ( composedMap , null , 2 ) ) ;
4943 console . log ( `${ TAG } Debug ID successfully copied.` ) ;
5044} catch {
51- error ( 'Debug ID copy failed: Cannot write updated composed sourcemap.' ) ;
45+ warnAndExit (
46+ 'Debug ID copy failed: Cannot write updated composed sourcemap.'
47+ ) ;
5248}
0 commit comments