Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency open to v8 #2175

Merged
merged 2 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"multimatch": "5.0.0",
"mz": "2.7.0",
"node-notifier": "9.0.1",
"open": "7.4.2",
"open": "8.4.0",
"parse-json": "5.2.0",
"promise-toolbox": "0.20.0",
"sign-addon": "3.11.0",
Expand Down
18 changes: 7 additions & 11 deletions src/cmd/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ export type DocsOptions = {
// eslint-disable-next-line max-len
export const url = 'https://extensionworkshop.com/documentation/develop/getting-started-with-web-ext/';

export default function docs(
export default async function docs(
params: DocsParams, {openUrl = open}: DocsOptions = {}
): Promise<void> {
return new Promise((resolve, reject) => {
openUrl(url, (error) => {
if (error) {
log.debug(`Encountered an error while opening URL ${url}`, error);
reject(error);
} else {
resolve();
}
});
});
try {
await openUrl(url);
} catch (error) {
log.debug(`Encountered an error while opening URL ${url}`, error);
throw error;
}
}
26 changes: 12 additions & 14 deletions tests/unit/test-cmd/test.docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@ import {it, describe} from 'mocha';
import * as sinon from 'sinon';
import {assert} from 'chai';

import {makeSureItFails} from '../helpers.js';
import defaultDocsCommand, {url} from '../../../src/cmd/docs.js';

describe('docs', () => {
it('passes the correct url to docs', () => {
const openUrl = sinon.spy((urlToOpen, callback) => callback(null));
return defaultDocsCommand({}, {openUrl}).then(() => {
sinon.assert.calledWith(openUrl, url);
});
it('passes the correct url to docs', async () => {
const openUrl = sinon.spy(async () => {});
await defaultDocsCommand({}, {openUrl});
sinon.assert.calledWith(openUrl, url);
});

it('throws an error when open fails', () => {
const openUrl = sinon.spy((urlToOpen, callback) => callback(
new Error('pretends this is an error from open()')
));
return defaultDocsCommand({}, {openUrl})
.then(makeSureItFails()).catch((error) => {
assert.match(error.message, /error from open()/);
});
it('throws an error when open fails', async () => {
const openUrl = sinon.spy(async () => {
throw new Error('pretends this is an error from open()');
});
await assert.isRejected(
defaultDocsCommand({}, {openUrl}),
/error from open()/
);
});
});