Skip to content

Instantly share code, notes, and snippets.

@rpl
Created January 22, 2021 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpl/1e5c11535c686c7e5be6cfead339c865 to your computer and use it in GitHub Desktop.
Save rpl/1e5c11535c686c7e5be6cfead339c865 to your computer and use it in GitHub Desktop.
Temporary patch attached to https://github.com/mozilla/web-ext/pull/2116 review comments
diff --git a/README.md b/README.md
index 3433d54..bcade89 100644
--- a/README.md
+++ b/README.md
@@ -121,25 +121,7 @@ You are able to execute command functions without any argument validation. If yo
// or...
import webExt from 'web-ext';
-// If you would like to run an extension on Firefox for Android:
-
-// Path to adb binary (optional parameter, auto-detected if missing)
-const adbBin = 'path/to/adb/binary';
-// Get an array of connected device ids (Array<string>)
-const deviceIds = await webExt.util.adb.listADBDevices(adbBin);
-const adbDevice = deviceIds[0];
-// Get an array of Firefox APKs (Array<string>) on a device
-const firefoxAPKs = await webExt.util.adb.listADBFirefoxAPKs(
- deviceId, adbBin
-);
-const firefoxApk = firefoxAPKs[0];
-
webExt.cmd.run({
- // Comment out next 3 lines to run the extension on firefox-desktop
- target: 'firefox-android',
- firefoxApk
- adbDevice
-
// To run an extension on desktop, uncomment next line
// firefox: '/path/to/Firefox-executable',
@@ -162,14 +144,26 @@ webExt.cmd.run({
});
```
-To get a list of connected adb devices, you may use the following function which takes an optional argument `adbBin` which is a path to custom adb binary:
-```js
-webExt.util.adb.listADBDevices(); // returns a Promise<Array<string>>
-```
+If you would like to run an extension on Firefox for Android:
-To get a list of installed firefox APK packages for an ADB client, you may use the following function which takes in deviceId(required) and adbBin(optional) as arguments:
```js
-webExt.util.adb.listADBFirefoxAPKs(deviceId); // returns a Promise<Array<string>>
+// Path to adb binary (optional parameter, auto-detected if missing)
+const adbBin = "/path/to/adb";
+// Get an array of device ids (Array<string>)
+const deviceIds = await webExt.util.adb.listADBDevices(adbBin);
+const adbDevice = ...
+// Get an array of Firefox APKs (Array<string>)
+const firefoxAPKs = await webExt.util.adb.listADBFirefoxAPKs(
+ deviceId, adbBin
+);
+const firefoxApk = ...
+
+webExt.cmd.run({
+ target: 'firefox-android',
+ firefoxApk,
+ adbDevice,
+ sourceDir: ...
+}).then((extensionRunner) => ...);
```
If you would like to control logging, you can access the logger object. Here is an example of turning on verbose logging:
@@ -200,7 +194,6 @@ webExt.cmd.run(
);
```
-
## Should I Use It?
Yes! The web-ext tool enables you to build and ship extensions for Firefox.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment