From 4a1884e5e5c8fb8bb71f3a4e715e06cd8ee1815b Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Thu, 17 Jul 2025 03:13:26 -0700 Subject: [PATCH] Exclude unimportant files from Electron build Summary: TSIA Changelog: [Internal] bypass-github-export-checks Reviewed By: huntie Differential Revision: D78351935 fbshipit-source-id: 7f71f3df3ecf8ce92891109b8d9f8e0a74361f21 --- scripts/debugger-shell/build-binary.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/debugger-shell/build-binary.js b/scripts/debugger-shell/build-binary.js index ed98c9269d6..46ba775ed21 100644 --- a/scripts/debugger-shell/build-binary.js +++ b/scripts/debugger-shell/build-binary.js @@ -44,6 +44,21 @@ async function main() { if (!pkg.main.startsWith('./dist/')) { throw new Error('Package not built yet. Run scripts/build/build.js first.'); } + + const IGNORE_PREFIXES = [ + 'src', + 'dist/node', + 'metainternal/build-mac', + '__tests__', + 'README.md', + ].map( + dirRelativeToPackageRoot => + path.join(PACKAGE_ROOT, dirRelativeToPackageRoot) + path.sep, + ); + const IGNORE_FILES = ['BUCK'].map(fileRelativeToPackageRoot => + path.join(PACKAGE_ROOT, fileRelativeToPackageRoot), + ); + await packager({ dir: PACKAGE_ROOT, icon: path.join(PACKAGE_ROOT, 'src/electron/resources/icon'), @@ -64,6 +79,10 @@ async function main() { OriginalFilename: `${APP_NAME}.exe`, }, overwrite: true, + ignore: [ + ...IGNORE_PREFIXES.map(prefix => new RegExp('^' + escapeRegex(prefix))), + ...IGNORE_FILES.map(file => new RegExp('^' + escapeRegex(file) + '$')), + ], }); } @@ -73,3 +92,7 @@ if (require.main === module) { process.exitCode = 1; }); } + +function escapeRegex(str /*: string */) /*: string */ { + return str.replace(/[-[\]\\/{}()*+?.^$|]/g, '\\$&'); +}