From 5ca50fa9893f27becd4fc3df03eccf0be6251bff Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Sun, 25 Sep 2016 02:08:04 +0530 Subject: [PATCH] fix: Support FIREFOX_BINARY again for Running web extension from /home/sj/Desktop/FOSS/Mozilla/web-ext run: InvalidManifest: Could not read manifest.json file at /home/sj/Desktop/FOSS/Mozilla/web-ext/manifest.json: Error: ENOENT: no such file or directory, open '/home/sj/Desktop/FOSS/Mozilla/web-ext/manifest.json' at _callee$ (/home/sj/Desktop/FOSS/Mozilla/web-ext/dist/webpack:/src/util/manifest.js:30:11) at tryCatch (/home/sj/Desktop/FOSS/Mozilla/web-ext/node_modules/regenerator-runtime/runtime.js:62:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/home/sj/Desktop/FOSS/Mozilla/web-ext/node_modules/regenerator-runtime/runtime.js:336:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/home/sj/Desktop/FOSS/Mozilla/web-ext/node_modules/regenerator-runtime/runtime.js:95:21) at step (/home/sj/Desktop/FOSS/Mozilla/web-ext/dist/webpack:/~/babel-runtime/helpers/asyncToGenerator.js:17:1) at /home/sj/Desktop/FOSS/Mozilla/web-ext/dist/webpack:/~/babel-runtime/helpers/asyncToGenerator.js:30:1 at run (/home/sj/Desktop/FOSS/Mozilla/web-ext/dist/webpack:/~/core-js/library/modules/es6.promise.js:87:1) at /home/sj/Desktop/FOSS/Mozilla/web-ext/dist/webpack:/~/core-js/library/modules/es6.promise.js:100:1 at flush (/home/sj/Desktop/FOSS/Mozilla/web-ext/dist/webpack:/~/core-js/library/modules/_microtask.js:18:1) at nextTickCallbackWith0Args (node.js:420:9) --- src/program.js | 2 +- tests/functional/test.cli.run.js | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/program.js b/src/program.js index 3c25b3160f..b99097e45e 100644 --- a/src/program.js +++ b/src/program.js @@ -218,7 +218,7 @@ Example: $0 --help run. }) .command('run', 'Run the web extension', commands.run, { 'firefox': { - alias: 'f', + alias: ['f', 'firefox-binary'], describe: 'Path to a Firefox executable such as firefox-bin. ' + 'If not specified, the default Firefox will be used.', demand: false, diff --git a/tests/functional/test.cli.run.js b/tests/functional/test.cli.run.js index a7fd2715f5..59d165d661 100644 --- a/tests/functional/test.cli.run.js +++ b/tests/functional/test.cli.run.js @@ -47,3 +47,44 @@ describe('web-ext run', () => { }); })); }); + +describe('web-ext run', () => { + it( + 'should accept: --no-reload --source-dir SRCDIR --firefox-binary FXPATH', + () => withTempAddonDir( + {addonPath: addonPath}, + (srcDir) => { + const argv = [ + 'run', '--verbose', '--no-reload', + '--source-dir', srcDir, + '--firefox-binary', fakeFirefoxPath, + ]; + const spawnOptions = { + env: { + PATH: process.env.PATH, + EXPECTED_MESSAGE: EXPECTED_MESSAGE, + addonPath: srcDir, + }, + }; + + const cmd = runCommand(webExt, argv, spawnOptions); + + return cmd.waitForExit.then(({exitCode, stdout, stderr}) => { + if (stdout.indexOf(EXPECTED_MESSAGE) < 0) { + reportRunCommandError({ + argv, + exitCode, + stdout, + stderr, + }, 'The fake Firefox binary has not been executed'); + } else if (exitCode !== 0) { + reportRunCommandError({ + argv, + exitCode, + stdout, + stderr, + }); + } + }); + })); +});