Skip to content

Commit adc4279

Browse files
committed
danger fix
1 parent f931c52 commit adc4279

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

.github/actions/diff-js-api-breaking-changes/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ runs:
1717
env:
1818
SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-breaking-changes
1919
run: |
20+
# Check if the file was changed in this PR, if not, exit early without saving to the output.json
21+
git diff --name-status | awk '{print $2}' | grep 'packages/react-native/ReactNativeApi.d.ts' || exit 0
22+
2023
node ./scripts/js-api/diff-api-snapshot \
2124
${{ github.workspace }}/packages/react-native/ReactNativeApi.d.ts \
2225
$SCRATCH_DIR/ReactNativeApi-after.d.ts \

private/react-native-bots/dangerfile.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,22 @@ const isFromPhabricator = body_contains('differential revision:');
3030
// Provides advice if a summary section is missing, or body is too short
3131
const includesSummary = body_contains('## summary', 'summary:');
3232

33-
const snapshot_output = JSON.parse(
34-
fs.readFileSync(
35-
path.join(
36-
process.env.RUNNER_TEMP,
37-
'diff-js-api-breaking-changes/output.json',
38-
),
39-
'utf8',
40-
),
33+
const snapshot_path = path.join(
34+
process.env.RUNNER_TEMP,
35+
'diff-js-api-breaking-changes/output.json',
4136
);
4237

43-
console.log('Snapshot output:', snapshot_output);
44-
45-
if (snapshot_output && snapshot_output.result !== 'NON_BREAKING') {
46-
const title = ':exclamation: JavaScript API change detected';
47-
const idea =
48-
'This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API. ' +
49-
'Please include a clear changelog message. ' +
50-
'This change will be subject to extra review.\n\n' +
51-
`This change was flagged as: <code>${snapshot_output.result}</code>`;
52-
warn(`${title} - <i>${idea}</i>`);
38+
if (fs.existsSync(snapshot_path)) {
39+
const snapshot_output = JSON.parse(fs.readFileSync(snapshot_path, 'utf8'));
40+
if (snapshot_output && snapshot_output.result !== 'NON_BREAKING') {
41+
const title = ':exclamation: JavaScript API change detected';
42+
const idea =
43+
'This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native&#39;s public JavaScript API. ' +
44+
'Please include a clear changelog message. ' +
45+
'This change will be subject to extra review.\n\n' +
46+
`This change was flagged as: <code>${snapshot_output.result}</code>`;
47+
warn(`${title} - <i>${idea}</i>`);
48+
}
5349
}
5450

5551
const hasNoUsefulBody =

0 commit comments

Comments
 (0)