Find ports where debuggable runtimes are listening.
This is part of the node-firefox project.
When runtimes have remote debugging enabled, they start a server that listens for incoming connections. This module can find those runtimes and in which port they are listening.
We can only detect Firefox Desktop and Firefox OS Simulators. Devices connected via USB are exposed via adb, which makes differentiation difficult with the method we are using to detect runtimes.
We also do not support Windows yet--we have no parser, tests or test data for Windows. But there are placeholders in the code marked with TODO: Windows
that indicate where the Windows code would need to be added. If you want to contribute, those are the gaps that need to be filled in order for this to work on Windows.
NOTE
This is a work in progress. Things will probably be missing and broken while we move from fx-ports
to firefox-ports
. Please have a look at the existing issues, and/or file more if you find any! :-)
git clone https://github.com/mozilla/node-firefox-ports.git
cd node-firefox-ports
npm install
If you want to update later on:
cd node-firefox-ports
git pull origin master
npm install
This module is not on npm yet.
findPorts(options) // returns a Promise
where options
is a plain Object with any of the following:
firefox
: look for Firefox Desktop instancesfirefoxOSSimulator
: look for Firefox OS Simulatorsdetailed
: query each found runtime for more information, such as the version, build time, processor, etc. The additional data will be added to the entry under a newdevice
field.
If no options
are provided, or if options
is an empty Object
({}
), then findPorts
will look for any runtimes, of any type.
var findPorts = require('./node-firefox-ports');
// (or require('node-firefox-ports') when it's on npm)
// Return all listening runtimes
findPorts().then(results) {
console.log(results);
});
// Returns only Firefox OS simulators, this time with error handling
findPorts({ firefoxOSSimulator: true }).then(function(results) {
console.log(results);
}, function(err) {
console.log(err);
});
// Returns only Firefox OS simulators, with extra detailed output
findPorts({ firefoxOSSimulator: true, detailed: true }).then(function(results) {
console.log(results);
});
After installing, you can simply run the following from the module folder:
npm test
To add a new unit test file, create a new file in the tests/unit
folder. Any file that matches test.*.js
will be run as a test by the appropriate test runner, based on the folder location.
We use gulp
behind the scenes to run the test; if you don't have it installed globally you can use npm gulp
from inside the project's root folder to run gulp
.
Because we have multiple contributors working on our projects, we value consistent code styles. It makes it easier to read code written by many people! :-)
Our tests include unit tests as well as code quality ("linting") tests that make sure our test pass a style guide and JSHint. Instead of submitting code with the wrong indentation or a different style, run the tests and you will be told where your code quality/style differs from ours and instructions on how to fix it.
This is based on initial work on fx-ports by Nicola Greco.
The command line utility binary has been removed for this initial iteration, since pretty much all the existing applications using this module were just using the JS code directly, not the binary.
This program is free software; it is distributed under an Apache License.
Copyright (c) 2014 Mozilla (Contributors).