Skip to content

Commit

Permalink
feat: You can now programmatically override the manifest parser in `c…
Browse files Browse the repository at this point in the history
…md.run()` (#1026)
  • Loading branch information
chrmod authored and kumar303 committed Aug 3, 2017
1 parent 6dde038 commit e48ac75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cmd/run.js
Expand Up @@ -8,7 +8,7 @@ import {
connectWithMaxRetries as defaultFirefoxClient,
} from '../firefox/remote';
import {createLogger} from '../util/logger';
import getValidatedManifest from '../util/manifest';
import defaultGetValidatedManifest from '../util/manifest';
import {
defaultReloadStrategy,
MultiExtensionRunner as DefaultMultiExtensionRunner,
Expand Down Expand Up @@ -43,6 +43,7 @@ export type CmdRunOptions = {|
shouldExitProgram?: boolean,
FirefoxDesktopExtensionRunner?: typeof DefaultFirefoxDesktopExtensionRunner,
MultiExtensionRunner?: typeof DefaultMultiExtensionRunner,
getValidatedManifest?: typeof defaultGetValidatedManifest,
|};

export default async function run(
Expand All @@ -58,6 +59,7 @@ export default async function run(
reloadStrategy = defaultReloadStrategy,
FirefoxDesktopExtensionRunner = DefaultFirefoxDesktopExtensionRunner,
MultiExtensionRunner = DefaultMultiExtensionRunner,
getValidatedManifest = defaultGetValidatedManifest,
}: CmdRunOptions = {}): Promise<Object> {

log.info(`Running web extension from ${sourceDir}`);
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test-cmd/test.run.js
Expand Up @@ -153,4 +153,12 @@ describe('run', () => {
assert.equal(reloadStrategy.called, false);
});

it('allows to replace manifest parser', async () => {
const cmd = prepareRun();
const getFakeManifest = sinon.spy();

await cmd.run({}, { getValidatedManifest: getFakeManifest });
assert.equal(getFakeManifest.called, true);
});

});

0 comments on commit e48ac75

Please sign in to comment.