alfy 0.12.2 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import Conf from 'conf';
2
2
  import {Options} from 'got';
3
3
 
4
4
  export interface FetchOptions extends Options {
5
+ // Deprecated, but left for backwards-compatibility.
5
6
  /**
6
7
  URL search parameters.
7
8
  */
package/index.js CHANGED
@@ -116,12 +116,17 @@ alfy.fetch = async (url, options) => {
116
116
  ...options,
117
117
  };
118
118
 
119
+ // Deprecated, but left for backwards-compatibility.
120
+ if (options.query) {
121
+ options.searchParams = options.query;
122
+ }
123
+
119
124
  if (typeof url !== 'string') {
120
- return Promise.reject(new TypeError(`Expected \`url\` to be a \`string\`, got \`${typeof url}\``));
125
+ throw new TypeError(`Expected \`url\` to be a \`string\`, got \`${typeof url}\``);
121
126
  }
122
127
 
123
128
  if (options.transform && typeof options.transform !== 'function') {
124
- return Promise.reject(new TypeError(`Expected \`transform\` to be a \`function\`, got \`${typeof options.transform}\``));
129
+ throw new TypeError(`Expected \`transform\` to be a \`function\`, got \`${typeof options.transform}\``);
125
130
  }
126
131
 
127
132
  const rawKey = url + JSON.stringify(options);
@@ -129,12 +134,12 @@ alfy.fetch = async (url, options) => {
129
134
  const cachedResponse = alfy.cache.get(key, {ignoreMaxAge: true});
130
135
 
131
136
  if (cachedResponse && !alfy.cache.isExpired(key)) {
132
- return Promise.resolve(cachedResponse);
137
+ return cachedResponse;
133
138
  }
134
139
 
135
140
  let response;
136
141
  try {
137
- response = await got(url, {searchParams: options.query}).json();
142
+ response = await got(url, options).json();
138
143
  } catch (error) {
139
144
  if (cachedResponse) {
140
145
  return cachedResponse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alfy",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
4
4
  "description": "Create Alfred workflows with ease",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/alfy",
package/readme.md CHANGED
@@ -351,7 +351,7 @@ URL to fetch.
351
351
 
352
352
  Type: `object`
353
353
 
354
- Any of the [`got` options](https://github.com/sindresorhus/got#options).
354
+ Any of the [`got` options](https://github.com/sindresorhus/got/tree/v11.8.3#api) and the below options.
355
355
 
356
356
  ###### json
357
357