From 59660bc0e10fa07cca3d2d2f89904cf347d0382b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Wed, 18 Mar 2026 09:29:02 -0700 Subject: [PATCH] Replace subprocess rm calls with Python stdlib (#56083) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56083 Changelog: [Internal] Removes direct calls to `rm` in the snapshot generator Reviewed By: cipolleschi Differential Revision: D96455685 fbshipit-source-id: e53dd3607b8cbb7566903c29af303377276b1ec5 --- scripts/cxx-api/parser/__main__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/cxx-api/parser/__main__.py b/scripts/cxx-api/parser/__main__.py index bdaac3147bc..432633c71a4 100644 --- a/scripts/cxx-api/parser/__main__.py +++ b/scripts/cxx-api/parser/__main__.py @@ -13,6 +13,7 @@ Usage: import argparse import os +import shutil import subprocess import sys import tempfile @@ -114,7 +115,7 @@ def build_snapshot_for_view( if os.path.exists(os.path.join(react_native_dir, "api")): if verbose: print("Deleting existing output directory") - subprocess.run(["rm", "-rf", os.path.join(react_native_dir, "api")]) + shutil.rmtree(os.path.join(react_native_dir, "api")) if verbose: print(f"Generating API view: {api_view}") @@ -163,7 +164,10 @@ def build_snapshot_for_view( # Delete the Doxygen config file if verbose: print("Deleting Doxygen config file") - subprocess.run(["rm", DOXYGEN_CONFIG_FILE], cwd=react_native_dir) + os.remove(os.path.join(react_native_dir, DOXYGEN_CONFIG_FILE)) + + if verbose: + print("Building snapshot") # build snapshot, convert to string, and save to file snapshot = build_snapshot(os.path.join(react_native_dir, "api", "xml"))