Skip to content

Commit 18ba211

Browse files
motiz88facebook-github-bot
authored andcommitted
Run prebuilt standalone shell directly from fbsource on laptops (#53878)
Summary: Pull Request resolved: #53878 Changelog: [Internal] Adds the `prebuiltBinaryPath` option to `unstable_spawnDebuggerShellWithArgs` and `unstable_prepareDebuggerShell`, for advanced integrations that need to change how the React Native DevTools prebuilt binary is distributed. Reviewed By: huntie Differential Revision: D82956699 fbshipit-source-id: 30f9c461c7d8f22a553f278bbe42b86742c98da7
1 parent 53f89ba commit 18ba211

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

packages/debugger-shell/src/node/index.flow.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,21 @@ async function unstable_spawnDebuggerShellWithArgs(
3030
{
3131
mode = 'detached',
3232
flavor = 'prebuilt',
33+
prebuiltBinaryPath,
3334
}: $ReadOnly<{
3435
// In 'syncAndExit' mode, the current process will block until the spawned process exits, and then it will exit
3536
// with the same exit code as the spawned process.
3637
// In 'detached' mode, the spawned process will be detached from the current process and the current process will
3738
// continue to run normally.
3839
mode?: 'syncThenExit' | 'detached',
3940
flavor?: DebuggerShellFlavor,
41+
prebuiltBinaryPath?: string,
4042
}> = {},
4143
): Promise<void> {
42-
const [binaryPath, baseArgs] = getShellBinaryAndArgs(flavor);
44+
const [binaryPath, baseArgs] = getShellBinaryAndArgs(
45+
flavor,
46+
prebuiltBinaryPath,
47+
);
4348

4449
return new Promise((resolve, reject) => {
4550
const child = spawn(binaryPath, [...baseArgs, ...args], {
@@ -109,15 +114,18 @@ export type DebuggerShellPreparationResult = $ReadOnly<{
109114
*/
110115
async function unstable_prepareDebuggerShell(
111116
flavor: DebuggerShellFlavor,
117+
{prebuiltBinaryPath}: {prebuiltBinaryPath?: string} = {},
112118
): Promise<DebuggerShellPreparationResult> {
113-
const [binaryPath, baseArgs] = getShellBinaryAndArgs(flavor);
119+
const [binaryPath, baseArgs] = getShellBinaryAndArgs(
120+
flavor,
121+
prebuiltBinaryPath,
122+
);
114123

115124
try {
116125
switch (flavor) {
117126
case 'prebuilt':
118-
const prebuiltResult = await prepareDebuggerShellFromDotSlashFile(
119-
DEVTOOLS_BINARY_DOTSLASH_FILE,
120-
);
127+
const prebuiltResult =
128+
await prepareDebuggerShellFromDotSlashFile(binaryPath);
121129
if (prebuiltResult.code !== 'success') {
122130
return prebuiltResult;
123131
}
@@ -149,10 +157,14 @@ async function unstable_prepareDebuggerShell(
149157

150158
function getShellBinaryAndArgs(
151159
flavor: DebuggerShellFlavor,
160+
prebuiltBinaryPath: ?string,
152161
): [string, Array<string>] {
153162
switch (flavor) {
154163
case 'prebuilt':
155-
return [require('fb-dotslash'), [DEVTOOLS_BINARY_DOTSLASH_FILE]];
164+
return [
165+
require('fb-dotslash'),
166+
[prebuiltBinaryPath ?? DEVTOOLS_BINARY_DOTSLASH_FILE],
167+
];
156168
case 'dev':
157169
return [
158170
// NOTE: Internally at Meta, this is aliased to a workspace that is

0 commit comments

Comments
 (0)