Skip to content

Commit 693fe42

Browse files
committed
chore: merge with master
2 parents fa20934 + 423c878 commit 693fe42

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<a name="4.0.0"></a>
2+
# [4.0.0](https://github.com/ipfs/js-ipfs-utils/compare/v3.0.0...v4.0.0) (2020-10-10)
3+
4+
5+
### Bug Fixes
6+
7+
* use native fetch if available ([#62](https://github.com/ipfs/js-ipfs-utils/issues/62)) ([9b0ff2f](https://github.com/ipfs/js-ipfs-utils/commit/9b0ff2f))
8+
9+
10+
111
<a name="3.0.0"></a>
212
# [3.0.0](https://github.com/ipfs/js-ipfs-utils/compare/v2.4.0...v3.0.0) (2020-08-18)
313

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ipfs-utils",
3-
"version": "3.0.0",
3+
"version": "4.0.0",
44
"description": "Package to aggregate shared logic and dependencies for the IPFS ecosystem",
55
"main": "src/index.js",
66
"author": "Hugo Dias <hugomrdias@gmail.com>",
@@ -17,7 +17,8 @@
1717
"./src/text-decoder.js": "./src/text-decoder.browser.js",
1818
"./src/temp-dir.js": "./src/temp-dir.browser.js",
1919
"./src/path-join.js": "./src/path-join.browser.js",
20-
"./test/files/glob-source.spec.js": false
20+
"./test/files/glob-source.spec.js": false,
21+
"@achingbrain/electron-fetch": false
2122
},
2223
"repository": "github:ipfs/js-ipfs-utils",
2324
"scripts": {
@@ -37,6 +38,7 @@
3738
"abort-controller": "^3.0.0",
3839
"any-signal": "^2.1.0",
3940
"buffer": "^5.6.0",
41+
"@achingbrain/electron-fetch": "^1.7.2",
4042
"err-code": "^2.0.0",
4143
"fs-extra": "^9.0.1",
4244
"is-electron": "^2.2.0",
@@ -46,6 +48,7 @@
4648
"nanoid": "^3.1.3",
4749
"native-abort-controller": "0.0.3",
4850
"native-fetch": "^2.0.0",
51+
"node-fetch": "^2.6.0",
4952
"stream-to-it": "^0.2.0",
5053
"it-to-stream": "^0.1.2"
5154
},

src/fetch.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
const { isElectronMain } = require('./env')
4+
5+
if (isElectronMain) {
6+
module.exports = require('@achingbrain/electron-fetch')
7+
} else {
8+
// use window.fetch if it is available, fall back to node-fetch if not
9+
module.exports = require('native-fetch')
10+
}

src/http/fetch.browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-env browser */
33

44
const { TimeoutError, AbortError } = require('./error')
5-
const fetch = require('native-fetch')
5+
const fetch = require('../fetch')
66
const { Request, Response, Headers } = fetch
77

88
/**

src/http/fetch.node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/** @type {import('node-fetch') & typeof fetch} */
55
// @ts-ignore
6-
const nodeFetch = require('native-fetch')
6+
const nodeFetch = require('../fetch')
77
const toStream = require('it-to-stream')
88
const { Buffer } = require('buffer')
99
const { Request, Response, Headers } = nodeFetch

0 commit comments

Comments
 (0)