From 60efc757d983a0701beb6714bc80be9ebdd2daa3 Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Thu, 17 Jul 2025 03:13:26 -0700 Subject: [PATCH] Implement --version flag Summary: Changelog: [Internal] Adds a basic `--version` command line flag to the RNDT shell. This will be used in code paths (including tests) that need to verify that the shell is executable, but do not need to actually display a window or hand over control to the main shell instance. bypass-github-export-checks Reviewed By: huntie Differential Revision: D78351936 fbshipit-source-id: e8982cfea6435da0ac9ea5f50d57c7642a8e2edb --- .../debugger-shell/src/electron/index.flow.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/debugger-shell/src/electron/index.flow.js b/packages/debugger-shell/src/electron/index.flow.js index 4dc67035f81..a07b0fc2afa 100644 --- a/packages/debugger-shell/src/electron/index.flow.js +++ b/packages/debugger-shell/src/electron/index.flow.js @@ -10,6 +10,22 @@ // $FlowFixMe[unclear-type] We have no Flow types for the Electron API. const {app} = require('electron') as any; +const util = require('util'); + +// Handle global command line arguments which don't require a window +// or the single instance lock to be held. +const { + values: {version = false}, +} = util.parseArgs({ + options: {version: {type: 'boolean'}}, + args: process.argv.slice(app.isPackaged ? 1 : 2), + strict: false, +}); +if (version) { + console.log(`${app.getName()} v${app.getVersion()}`); + // Not app.quit() - we want to exit immediately without initialising the graphical subsystem. + app.exit(0); +} const gotTheLock = app.requestSingleInstanceLock({ argv: process.argv.slice(2),