Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
refactor: replace run-* with async, ipfs->ipfs-exec
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire authored and daviddias committed Sep 30, 2016
1 parent 5fe4674 commit 8509199
Show file tree
Hide file tree
Showing 25 changed files with 39 additions and 31 deletions.
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

const gulp = require('gulp')
const parallel = require('run-parallel')
const series = require('run-series')
const parallel = require('async/parallel')
const series = require('async/series')
const createTempNode = require('./test/utils/temp-node')
const API = require('./src/http-api')

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"transform-loader": "^0.2.3"
},
"dependencies": {
"async": "^2.0.1",
"babel-runtime": "^6.11.6",
"bl": "^1.1.2",
"boom": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/config/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const spawn = require('child_process').spawn
const fs = require('fs')
const temp = require('temp')
const waterfall = require('run-waterfall')
const waterfall = require('async/waterfall')
const debug = require('debug')
const log = debug('cli:config')
log.error = debug('cli:config:error')
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/files/cat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const waterfall = require('run-waterfall')
const waterfall = require('async/waterfall')
const debug = require('debug')
const utils = require('../../utils')
const log = debug('cli:files')
Expand Down
1 change: 1 addition & 0 deletions src/cli/commands/files/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function fileHandler (dir) {
file.content.pipe(fs.createWriteStream(target))
.once('error', cb)
.once('end', cb)
return
}
cb()
})
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/go-online.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const series = require('run-series')
const series = require('async/series')
const Bitswap = require('ipfs-bitswap')

module.exports = function goOnline (self) {
Expand Down
9 changes: 2 additions & 7 deletions src/core/components/object.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const mDAG = require('ipfs-merkle-dag')
const waterfall = require('run-waterfall')
const waterfall = require('async/waterfall')
const promisify = require('promisify-es6')
const bs58 = require('bs58')
const DAGNode = mDAG.DAGNode
Expand Down Expand Up @@ -69,12 +69,7 @@ module.exports = function object (self) {
cb(err, node)
})
}
], (err, node) => {
if (err) {
return cb(err)
}
cb(null, node)
})
], cb)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/http-api/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const parallel = require('run-parallel')
const parallel = require('async/parallel')
const Hapi = require('hapi')
const debug = require('debug')
const fs = require('fs')
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test-bitswap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const bs58 = require('bs58')
const HttpAPI = require('../../src/http-api')
const createTempNode = require('../utils/temp-node')
const repoPath = require('./index').repoPath
const ipfs = require('../utils/ipfs')(repoPath)
const ipfs = require('../utils/ipfs-exec')(repoPath)

describe('bitswap', () => {
let node
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const expect = require('chai').expect
const repoPath = require('./index').repoPath
const describeOnlineAndOffline = require('../utils/on-and-off')
const ipfs = require('../utils/ipfs')(repoPath)
const ipfs = require('../utils/ipfs-exec')(repoPath)

describe('block', () => {
describeOnlineAndOffline(repoPath, () => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

const expect = require('chai').expect
const repoPath = require('./index').repoPath
const ipfs = require('../utils/ipfs')(repoPath)
const ipfs = require('../utils/ipfs-exec')(repoPath)
const describeOnlineAndOffline = require('../utils/on-and-off')

describe('bootstrap', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const expect = require('chai').expect
const repoPath = require('./index').repoPath
const ipfsBase = require('../utils/ipfs')
const ipfsBase = require('../utils/ipfs-exec')
const ipfs = ipfsBase(repoPath)
const describeOnlineAndOffline = require('../utils/on-and-off')

Expand Down
2 changes: 1 addition & 1 deletion test/cli/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const expect = require('chai').expect
const fs = require('fs')
const path = require('path')
const repoPath = require('./index').repoPath
const ipfs = require('../utils/ipfs')(repoPath)
const ipfs = require('../utils/ipfs-exec')(repoPath)
const describeOnlineAndOffline = require('../utils/on-and-off')

describe('config', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const repoPath = require('./index').repoPath
const fs = require('fs')
const path = require('path')
const describeOnlineAndOffline = require('../utils/on-and-off')
const ipfs = require('../utils/ipfs')(repoPath)
const ipfs = require('../utils/ipfs-exec')(repoPath)

describe('files', () => {
describeOnlineAndOffline(repoPath, () => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const expect = require('chai').expect
const repoPath = require('./index').repoPath
const describeOnlineAndOffline = require('../utils/on-and-off')
const ipfs = require('../utils/ipfs')(repoPath)
const ipfs = require('../utils/ipfs-exec')(repoPath)

describe('id', () => {
describeOnlineAndOffline(repoPath, () => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const expect = require('chai').expect
const path = require('path')
const fs = require('fs')
const clean = require('../utils/clean')
const ipfsCmd = require('../utils/ipfs')
const ipfsCmd = require('../utils/ipfs-exec')

describe('init', function () {
this.timeout(60 * 1000)
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const expect = require('chai').expect
const repoPath = require('./index').repoPath
const describeOnlineAndOffline = require('../utils/on-and-off')
const ipfs = require('../utils/ipfs')(repoPath)
const ipfs = require('../utils/ipfs-exec')(repoPath)

describe('object', () => {
describeOnlineAndOffline(repoPath, () => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test-swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const expect = require('chai').expect
const HttpAPI = require('../../src/http-api')
const createTempNode = require('../utils/temp-node')
const repoPath = require('./index').repoPath
const ipfs = require('../utils/ipfs')(repoPath)
const ipfs = require('../utils/ipfs-exec')(repoPath)

describe('swarm', function () {
this.timeout(30 * 1000)
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const expect = require('chai').expect
const pkgversion = require('../../package.json').version
const repoPath = require('./index').repoPath
const describeOnlineAndOffline = require('../utils/on-and-off')
const ipfs = require('../utils/ipfs')(repoPath)
const ipfs = require('../utils/ipfs-exec')(repoPath)

describe('version', () => {
describeOnlineAndOffline(repoPath, () => {
Expand Down
6 changes: 3 additions & 3 deletions test/core/both/test-bitswap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

const expect = require('chai').expect
const _ = require('lodash')
const series = require('run-series')
const waterfall = require('run-waterfall')
const parallel = require('run-parallel')
const series = require('async/series')
const waterfall = require('async/waterfall')
const parallel = require('async/parallel')
const leftPad = require('left-pad')
const Block = require('ipfs-block')
const bs58 = require('bs58')
Expand Down
2 changes: 1 addition & 1 deletion test/core/browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env mocha */
'use strict'

const series = require('run-series')
const series = require('async/series')
const Store = require('idb-pull-blob-store')
const _ = require('lodash')
const pull = require('pull-stream')
Expand Down
2 changes: 1 addition & 1 deletion test/utils/factory-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const isNode = require('detect-node')
const IPFSRepo = require('ipfs-repo')
const cleanRepo = require('../clean')
const IPFS = require('../../../src/core')
const series = require('run-series')
const series = require('async/series')
const defaultConfig = require('./default-config.json')

module.exports = Factory
Expand Down
2 changes: 1 addition & 1 deletion test/utils/factory-http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const IPFSAPI = require('ipfs-api')
const IPFS = require('../../../src/core')
const cleanRepo = require('../clean')
const HTTPAPI = require('../../../src/http-api')
const series = require('run-series')
const series = require('async/series')
const defaultConfig = require('./default-config.json')

module.exports = Factory
Expand Down
11 changes: 11 additions & 0 deletions test/utils/ipfs.js → test/utils/ipfs-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ const execa = require('execa')
const expect = require('chai').expect
const _ = require('lodash')

// This is our new test utility to easily check and execute
// ipfs cli commands.
//
// The top level export is a function that can be passed a `repoPath`
// and optional `opts` to customize the execution of the commands.
// This function returns the actual executer, which consists of
// `ipfs('files get <hash>')` and `ipfs.fail('files get <hash>')`
// The first one executes and asserts that the command ran successfully
// and returns a promise which is resolved to `stdout` of the command.
// The `.fail` variation asserts that the command exited with `Code > 0`
// and returns a promise that resolves to `stderr`.
module.exports = (repoPath, opts) => {
const env = _.clone(process.env)
env.IPFS_PATH = repoPath
Expand Down
2 changes: 1 addition & 1 deletion test/utils/temp-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const expect = require('chai').expect
const leftPad = require('left-pad')
const series = require('run-series')
const series = require('async/series')

const IPFS = require('../../src/core')
const createTempRepo = require('./temp-repo')
Expand Down

0 comments on commit 8509199

Please sign in to comment.