Skip to content

Commit

Permalink
fix: use fetch in electron renderer and electron-fetch in main (#3251)
Browse files Browse the repository at this point in the history
Lets us run test on Linux which roughly halves the amount of time Electron CI tasks take.
  • Loading branch information
achingbrain authored Oct 10, 2020
1 parent 916fe40 commit 93a0637
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 15 deletions.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@
"dep-check": "aegir dep-check"
},
"dependencies": {
"abort-controller": "^3.0.0",
"any-signal": "^2.0.0",
"bignumber.js": "^9.0.0",
"cids": "^1.0.0",
"debug": "^4.1.1",
"form-data": "^3.0.0",
"ipfs-core-utils": "^0.4.0",
"ipfs-utils": "^3.0.0",
"ipfs-utils": "^4.0.0",
"ipld-block": "^0.10.1",
"ipld-dag-cbor": "^0.17.0",
"ipld-dag-pb": "^0.20.0",
Expand All @@ -65,7 +64,7 @@
"multicodec": "^2.0.1",
"multihashes": "^3.0.1",
"nanoid": "^3.1.12",
"node-fetch": "^2.6.0",
"native-abort-controller": "~0.0.3",
"parse-duration": "^0.4.4",
"stream-to-it": "^0.2.2",
"uint8arrays": "^1.1.0"
Expand All @@ -75,7 +74,7 @@
"cross-env": "^7.0.0",
"go-ipfs": "^0.7.0",
"interface-ipfs-core": "^0.140.0",
"ipfsd-ctl": "^7.0.0",
"ipfsd-ctl": "^7.0.2",
"it-all": "^1.0.4",
"it-concat": "^1.0.1",
"it-pipe": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/add-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const configure = require('./lib/configure')
const multipartRequest = require('./lib/multipart-request')
const toUrlSearchParams = require('./lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure((api) => {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/block/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const multipartRequest = require('../lib/multipart-request')
const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/config/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const multipartRequest = require('../lib/multipart-request')
const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
return async (config, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion src/dag/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const configure = require('../lib/configure')
const multipartRequest = require('../lib/multipart-request')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')
const multicodec = require('multicodec')

module.exports = configure((api, opts) => {
Expand Down
2 changes: 1 addition & 1 deletion src/files/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const configure = require('../lib/configure')
const multipartRequest = require('../lib/multipart-request')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
return async (path, input, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/multipart-request.browser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const normaliseInput = require('ipfs-core-utils/src/files/normalise-input')
const normaliseInput = require('ipfs-core-utils/src/files/normalise-input/index.browser')
const modeToString = require('./mode-to-string')
const mtimeToObject = require('./mtime-to-object')
const { File, FormData } = require('ipfs-utils/src/globalthis')
Expand Down
5 changes: 5 additions & 0 deletions src/lib/multipart-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const modeToString = require('../lib/mode-to-string')
const mtimeToObject = require('../lib/mtime-to-object')
const merge = require('merge-options').bind({ ignoreUndefined: true })
const toStream = require('it-to-stream')
const { isElectronRenderer } = require('ipfs-utils/src/env')

async function multipartRequest (source = '', abortController, headers = {}, boundary = `-----------------------------${nanoid()}`) {
async function * streamFiles (source) {
Expand Down Expand Up @@ -73,3 +74,7 @@ async function multipartRequest (source = '', abortController, headers = {}, bou
}

module.exports = multipartRequest

if (isElectronRenderer) {
module.exports = require('./multipart-request.browser')
}
2 changes: 1 addition & 1 deletion src/object/patch/append-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const multipartRequest = require('../../lib/multipart-request')
const configure = require('../../lib/configure')
const toUrlSearchParams = require('../../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
return async (cid, data, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion src/object/patch/set-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const multipartRequest = require('../../lib/multipart-request')
const configure = require('../../lib/configure')
const toUrlSearchParams = require('../../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
return async (cid, data, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion src/object/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const multipartRequest = require('../lib/multipart-request')
const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')
const unit8ArrayToString = require('uint8arrays/to-string')
const uint8ArrayFromString = require('uint8arrays/from-string')

Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const multipartRequest = require('../lib/multipart-request')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
return async (topic, data, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/subscription-tracker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

class SubscriptionTracker {
constructor () {
Expand Down

0 comments on commit 93a0637

Please sign in to comment.