From 47d723027d98da92045f7f037dbe3c6e009fa623 Mon Sep 17 00:00:00 2001 From: Kumar McMillan Date: Mon, 27 Jun 2016 12:17:46 -0500 Subject: [PATCH] feat: `web-ext run --pre-install` no longer connects to the remote debugger. This allows you to run the extension even if there are problems connecting to the debugger. --- src/cmd/run.js | 16 ++++++++++++---- tests/test-cmd/test.run.js | 9 +++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/cmd/run.js b/src/cmd/run.js index e679eb57a6..9e6f4de8cf 100644 --- a/src/cmd/run.js +++ b/src/cmd/run.js @@ -98,6 +98,9 @@ export default function run( '--pre-install'); noReload = true; } + // When not pre-installing the extension, we require a remote + // connection to Firefox. + const requiresRemote = !preInstall; function createRunner() { return getValidatedManifest(sourceDir) @@ -142,19 +145,24 @@ export default function run( }); }) .then((config) => { - return firefoxClient().then((client) => { - return {client, ...config}; - }); + if (requiresRemote) { + return firefoxClient().then((client) => { + return {client, ...config}; + }); + } else { + return config; + } }) .then((config) => { return new Promise( (resolve) => { - const {runner, client} = config; + const {runner} = config; if (installed) { log.debug('Not installing as temporary add-on because the ' + 'add-on was already installed'); resolve(); } else { + const {client} = config; resolve(runner.installAsTemporaryAddon(client)); } }) diff --git a/tests/test-cmd/test.run.js b/tests/test-cmd/test.run.js index 2c482698d0..62c1ae5ab0 100644 --- a/tests/test-cmd/test.run.js +++ b/tests/test-cmd/test.run.js @@ -182,6 +182,15 @@ describe('run', () => { }); }); + it('will not connect to the debugger when using --pre-install', () => { + const cmd = prepareRun(); + const {firefoxClient} = cmd.options; + + return cmd.run({preInstall: true}).then(() => { + assert.equal(firefoxClient.called, false); + }); + }); + it('allows you to opt out of extension reloading', () => { const cmd = prepareRun(); const {reloadStrategy} = cmd.options;