Skip to content

Commit bf4c856

Browse files
Merge pull request #919 from DataDog/marcosaia/fix/copy-debug-id-error
[FIX] Make copy-debug-id errors non-fatal
2 parents 5bf6e97 + e0b7f94 commit bf4c856

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

packages/core/scripts/copy-debug-id.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,31 @@ const [, , packagerPath, composedPath] = argv;
99

1010
const 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

2317
const 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

3428
const packagerMap = safeLoad(packagerPath);
3529
const composedMap = safeLoad(composedPath);
3630

3731
if (!packagerMap?.debugId) {
38-
error('No debugId found in packager sourcemap.');
32+
warnAndExit('No debugId found in packager sourcemap.');
3933
}
4034

4135
if (composedMap?.debugId) {
42-
error('Composed sourcemap already contains a debugId.');
36+
warnAndExit('Composed sourcemap already contains a debugId.');
4337
}
4438

4539
composedMap.debugId = packagerMap.debugId;
@@ -48,5 +42,7 @@ try {
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

Comments
 (0)