Skip to content

Commit e2c9751

Browse files
committed
Upgrade dependencies
1 parent 1bf01cf commit e2c9751

File tree

9 files changed

+38
-34
lines changed

9 files changed

+38
-34
lines changed

cleanup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import process from 'node:process';
33
import {fileURLToPath} from 'node:url';
44
import path from 'node:path';
5-
import execa from 'execa';
5+
import {execa} from 'execa';
66

77
const __dirname = path.dirname(fileURLToPath(import.meta.url));
88

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Conf from 'conf';
22
import {Options} from 'got';
33

4-
export interface FetchOptions extends Options {
4+
export interface FetchOptions extends Partial<Options> {
55
// Deprecated, but left for backwards-compatibility.
66
/**
77
URL search parameters.
88
*/
9-
readonly query?: string | Record<string, string | number | boolean | null | undefined> | URLSearchParams | undefined;
9+
readonly query?: string | Record<string, string | number | boolean | undefined> | URLSearchParams | undefined;
1010

1111
/**
1212
Number of milliseconds this request should be cached.

index.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import process from 'node:process';
33
import {createRequire} from 'node:module';
44
import Conf from 'conf';
55
import got from 'got';
6-
import hookStd from 'hook-std';
6+
import {hookStderr} from 'hook-std';
77
import loudRejection from 'loud-rejection';
88
import cleanStack from 'clean-stack';
9-
import dotProp from 'dot-prop';
9+
import {getProperty} from 'dot-prop';
1010
import AlfredConfig from 'alfred-config';
1111
import updateNotification from './lib/update-notification.js';
1212

@@ -50,7 +50,7 @@ alfy.matches = (input, list, item) => {
5050

5151
return list.filter(listItem => {
5252
if (typeof item === 'string') {
53-
listItem = dotProp.get(listItem, item);
53+
listItem = getProperty(listItem, item);
5454
}
5555

5656
if (typeof listItem === 'string') {
@@ -116,17 +116,22 @@ alfy.fetch = async (url, options) => {
116116
...options,
117117
};
118118

119+
const {transform, maxAge} = options;
120+
delete options.transform;
121+
delete options.maxAge;
122+
119123
// Deprecated, but left for backwards-compatibility.
120124
if (options.query) {
121125
options.searchParams = options.query;
126+
delete options.query;
122127
}
123128

124129
if (typeof url !== 'string') {
125130
throw new TypeError(`Expected \`url\` to be a \`string\`, got \`${typeof url}\``);
126131
}
127132

128-
if (options.transform && typeof options.transform !== 'function') {
129-
throw new TypeError(`Expected \`transform\` to be a \`function\`, got \`${typeof options.transform}\``);
133+
if (transform && typeof transform !== 'function') {
134+
throw new TypeError(`Expected \`transform\` to be a \`function\`, got \`${typeof transform}\``);
130135
}
131136

132137
const rawKey = url + JSON.stringify(options);
@@ -157,10 +162,10 @@ alfy.fetch = async (url, options) => {
157162
throw error;
158163
}
159164

160-
const data = options.transform ? options.transform(response) : response;
165+
const data = transform ? transform(response) : response;
161166

162-
if (options.maxAge) {
163-
alfy.cache.set(key, data, {maxAge: options.maxAge});
167+
if (maxAge) {
168+
alfy.cache.set(key, data, {maxAge});
164169
}
165170

166171
return data;
@@ -180,6 +185,6 @@ alfy.icon = {
180185

181186
loudRejection(alfy.error);
182187
process.on('uncaughtException', alfy.error);
183-
hookStd.stderr(alfy.error);
188+
hookStderr(alfy.error);
184189

185190
export default alfy;

index.test-d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
21
import {expectType} from 'tsd';
32
import alfy, {ScriptFilterItem} from './index.js';
43

init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import process from 'node:process';
33
import path from 'node:path';
44
import {fileURLToPath} from 'node:url';
5-
import execa from 'execa';
5+
import {execa} from 'execa';
66

77
const __dirname = path.dirname(fileURLToPath(import.meta.url));
88

lib/update-notification.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {readPackageUpAsync} from 'read-pkg-up';
1+
import {readPackageUp} from 'read-pkg-up';
22
import alfredNotifier from 'alfred-notifier';
33

44
export default async function updateNotification() {
5-
const {package: pkg} = await readPackageUpAsync();
5+
const {package: pkg} = await readPackageUp();
66
const alfy = (pkg || {}).alfy || {};
77

88
if (alfy.updateNotification !== false) {

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,26 @@
3737
"mac"
3838
],
3939
"dependencies": {
40-
"alfred-config": "^0.2.2",
40+
"alfred-config": "^0.2.3",
4141
"alfred-link": "^0.3.1",
4242
"alfred-notifier": "^0.2.3",
4343
"cache-conf": "^0.6.0",
4444
"clean-stack": "^4.1.0",
45-
"conf": "^10.0.1",
46-
"dot-prop": "^6.0.1",
47-
"execa": "^5.1.1",
48-
"got": "^11.8.2",
49-
"hook-std": "^2.0.0",
45+
"conf": "^10.1.1",
46+
"dot-prop": "^7.2.0",
47+
"execa": "^6.1.0",
48+
"got": "^12.0.3",
49+
"hook-std": "^3.0.0",
5050
"loud-rejection": "^2.2.0",
51-
"read-pkg-up": "^8.0.0"
51+
"read-pkg-up": "^9.1.0"
5252
},
5353
"devDependencies": {
54-
"ava": "^3.15.0",
54+
"ava": "^4.1.0",
5555
"delay": "^5.0.0",
56-
"nock": "^13.1.1",
56+
"nock": "^13.2.4",
5757
"tempfile": "^4.0.0",
58-
"tsd": "^0.17.0",
59-
"typescript": "^4.3.5",
60-
"xo": "^0.43.0"
58+
"tsd": "^0.19.1",
59+
"typescript": "^4.6.3",
60+
"xo": "^0.48.0"
6161
}
6262
}

test/fetch.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test('transform not a function', async t => {
3030
test('transform', async t => {
3131
const alfy = createAlfy();
3232
const result = await alfy.fetch(`${URL}/no-cache`, {
33-
transform: response => {
33+
transform(response) {
3434
response.unicorn = 'rainbow';
3535
return response;
3636
},
@@ -45,12 +45,12 @@ test('transform', async t => {
4545
test('cache', async t => {
4646
const alfy = createAlfy();
4747

48-
t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000}), {hello: 'world'});
49-
t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000}), {hello: 'world'});
48+
t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000, retry: {}}), {hello: 'world'});
49+
t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000, retry: {}}), {hello: 'world'});
5050

5151
await delay(5000);
5252

53-
t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000}), {hello: 'world!'});
53+
t.deepEqual(await alfy.fetch(`${URL}/cache`, {maxAge: 5000, retry: {}}), {hello: 'world!'});
5454
});
5555

5656
test('cache key', async t => {

test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import hookStd from 'hook-std';
2+
import {hookStdout} from 'hook-std';
33
import {alfy} from './_utils.js';
44

55
const alfyInstance = alfy();
@@ -12,7 +12,7 @@ test('default', t => {
1212
});
1313

1414
test.serial('.error()', async t => {
15-
const promise = hookStd.stdout(output => {
15+
const promise = hookStdout(output => {
1616
promise.unhook();
1717
t.is(JSON.parse(output).items[0].title, 'Error: foo');
1818
});

0 commit comments

Comments
 (0)