Add exec Node API to FlipperLib

Summary: Changelog: Allow flipper plugins to run "exec" Node API on Flipper server.

Reviewed By: mweststrate

Differential Revision: D32881149

fbshipit-source-id: 46486a47ee9824ca68897c19fd86b4afc7f8bf1d
This commit is contained in:
Andrey Goncharov
2021-12-10 06:34:37 -08:00
committed by Facebook GitHub Bot
parent 8ca2c59499
commit e458ae76f9
10 changed files with 121 additions and 3 deletions

View File

@@ -7,8 +7,8 @@
* @format
*/
import {_setFlipperLibImplementation} from 'flipper-plugin';
import type {Logger} from 'flipper-common';
import {_setFlipperLibImplementation, RemoteNodeAPI} from 'flipper-plugin';
import type {BufferEncoding, ExecOptions, Logger} from 'flipper-common';
import type {Store} from '../reducers';
import createPaste from '../fb-stubs/createPaste';
import type BaseDevice from '../devices/BaseDevice';
@@ -63,5 +63,19 @@ export function initializeFlipperLibImplementation(
appPath: renderHost.serverConfig.paths.appPath,
homePath: renderHost.serverConfig.paths.homePath,
},
removeNodeAPI: {
childProcess: {
exec: (async (
command: string,
options?: ExecOptions & {encoding?: BufferEncoding},
) =>
renderHost.flipperServer.exec(
'node-api-exec',
command,
options,
)) as RemoteNodeAPI['childProcess']['exec'],
},
fs: {},
},
});
}