Skip to content

Commit

Permalink
refactor: Rename binaryArgs to args
Browse files Browse the repository at this point in the history
  • Loading branch information
denar90 committed Mar 28, 2019
1 parent baa8cab commit 14af123
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 31 deletions.
6 changes: 3 additions & 3 deletions src/cmd/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type CmdRunParams = {|
sourceDir: string,
startUrl?: Array<string>,
target?: Array<string>,
binaryArgs?: Array<string>,
args?: Array<string>,

// Android CLI options.
adbBin?: string,
Expand Down Expand Up @@ -78,7 +78,7 @@ export default async function run(
adbPort,
adbDevice,
firefoxApk,
binaryArgs,
args,
}: CmdRunParams,
{
buildExtension = defaultBuildExtension,
Expand Down Expand Up @@ -109,7 +109,7 @@ export default async function run(
extensions: [{sourceDir, manifestData}],
keepProfileChanges,
startUrl,
binaryArgs,
args,
desktopNotifications,
};

Expand Down
2 changes: 1 addition & 1 deletion src/extension-runners/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type ExtensionRunnerParams = {|
profilePath?: string,
keepProfileChanges: boolean,
startUrl: ?string | ?Array<string>,
binaryArgs?: Array<string>,
args?: Array<string>,

// Common injected dependencies.
desktopNotifications: typeof defaultDesktopNotifications,
Expand Down
2 changes: 1 addition & 1 deletion src/extension-runners/firefox-android.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ignoredParams = {
browserConsole: '--browser-console',
preInstall: '--pre-install',
startUrl: '--start-url',
binaryArgs: '--binary-args',
args: '--args',
};

const getIgnoredParamsWarningsMessage = (optionName) => {
Expand Down
8 changes: 4 additions & 4 deletions src/extension-runners/firefox-desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,21 +217,21 @@ export class FirefoxDesktopExtensionRunner {
startUrl,
firefoxApp,
firefoxClient,
binaryArgs = [],
args = [],
} = this.params;

if (browserConsole) {
binaryArgs.push('-jsconsole');
args.push('-jsconsole');
}
if (startUrl) {
const urls = Array.isArray(startUrl) ? startUrl : [startUrl];
for (const url of urls) {
binaryArgs.push('--url', url);
args.push('--url', url);
}
}

this.runningInfo = await firefoxApp.run(this.profile, {
firefoxBinary, binaryArgs,
firefoxBinary, args,
});

this.runningInfo.firefox.on('close', () => {
Expand Down
7 changes: 3 additions & 4 deletions src/firefox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export type FirefoxRunnerParams = {|
'no-remote'?: boolean,
'foreground'?: boolean,
'listen': number,
'binary-args'?: Array<string> | string,
'args'?: Array<string> | string,
'env'?: {
[key: string]: string
},
Expand Down Expand Up @@ -122,7 +122,6 @@ export type FirefoxRunOptions = {|
fxRunner?: FirefoxRunnerFn,
findRemotePort?: RemotePortFinderFn,
firefoxBinary?: string,
binaryArgs?: Array<string>,
args?: Array<any>,
|};

Expand All @@ -134,7 +133,7 @@ export async function run(
{
fxRunner = defaultFxRunner,
findRemotePort = defaultRemotePortFinder,
firefoxBinary, binaryArgs,
firefoxBinary, args,
}: FirefoxRunOptions = {}
): Promise<FirefoxInfo> {

Expand All @@ -143,9 +142,9 @@ export async function run(
const remotePort = await findRemotePort();

const results = await fxRunner({
args,
// if this is falsey, fxRunner tries to find the default one.
'binary': firefoxBinary,
'binary-args': binaryArgs,
// This ensures a new instance of Firefox is created. It has nothing
// to do with the devtools remote debugger.
'no-remote': true,
Expand Down
3 changes: 2 additions & 1 deletion src/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ Example: $0 --help run.
demandOption: false,
type: 'boolean',
},
'binary-args': {
'args': {
alias: ['arg'],
describe: 'Additional CLI options passed to the Browser binary',
demandOption: false,
type: 'array',
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test-cmd/test.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('run', () => {
firefox: '/path/to/custom/bin/firefox',
pref: {'my.custom.pref': 'value'},
firefoxProfile: '/path/to/custom/profile',
binaryArgs: ['-headless=false'],
args: ['-headless=false'],
};

await cmd.run(runOptions);
Expand All @@ -131,7 +131,7 @@ describe('run', () => {
firefoxBinary: runnerParams.firefoxBinary,
customPrefs: runnerParams.customPrefs,
firefoxProfile: runnerParams.profilePath,
binaryArgs: runnerParams.binaryArgs,
args: runnerParams.args,
}, expectedRunnerParams);
assert.equal(runnerParams.extensions.length, 1);
assert.equal(runnerParams.extensions[0].sourceDir, cmd.argv.sourceDir);
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test-extension-runners/test.firefox-android.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,9 @@ describe('util/extension-runners/firefox-android', () => {
),
},
{
params: {binaryArgs: ['-headless=false']},
params: {args: ['-headless=false']},
expectedMessage: (
/Android target does not support --binary-args/
/Android target does not support --args/
),
},
];
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/test-extension-runners/test.firefox-desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('util/extension-runners/firefox-desktop', () => {
}));
});

async function testBinaryArgs(extensionRunnerParams, expectedBinaryArgs) {
async function testArgs(extensionRunnerParams, expectedArgs) {
const {params} = prepareExtensionRunnerParams({
params: {
...extensionRunnerParams,
Expand All @@ -172,39 +172,39 @@ describe('util/extension-runners/firefox-desktop', () => {
params.firefoxApp.run,
sinon.match.any,
sinon.match.has(
'binaryArgs',
sinon.match.array.deepEquals(expectedBinaryArgs)
'args',
sinon.match.array.deepEquals(expectedArgs)
)
);
}

it('passes -jsconsole when --browser-console is specified', async () => {
await testBinaryArgs({
await testArgs({
browserConsole: true,
}, [
'-jsconsole',
]);
});

it('passes single url parameter to Firefox when specified', async () => {
await testBinaryArgs({
await testArgs({
startUrl: 'url1',
}, [
'--url', 'url1',
]);
});

it('passes multiple url parameters to Firefox when specified', async () => {
await testBinaryArgs({
await testArgs({
startUrl: ['url1', 'url2'],
}, [
'--url', 'url1', '--url', 'url2',
]);
});

it('passes binaryArgs to Firefox', async () => {
await testBinaryArgs({
binaryArgs: ['-headless=true', '-jsconsole'],
it('passes args to Firefox', async () => {
await testArgs({
args: ['-headless=true', '-jsconsole'],
}, [
'-headless=true', '-jsconsole',
]);
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/test-firefox/test.firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,11 @@ describe('firefox', () => {

it('passes binary args to Firefox', () => {
const fxRunner = createFakeFxRunner();
const binaryArgs = '--safe-mode';
return runFirefox({fxRunner, binaryArgs})
const args = '--safe-mode';
return runFirefox({fxRunner, args})
.then(() => {
sinon.assert.called(fxRunner);
assert.equal(fxRunner.firstCall.args[0]['binary-args'],
binaryArgs);
assert.equal(fxRunner.firstCall.args[0].args, args);
});
});

Expand Down

0 comments on commit 14af123

Please sign in to comment.