Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 21d2f33

Browse files
committed
fix aegir setup (test->src), make it buildable, remove require(raw! for fs, stop requiring fs inside functions (breaks webpack)
1 parent 3130b8f commit 21d2f33

14 files changed

+17
-30
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "interface-ipfs-core",
33
"version": "0.1.5",
44
"description": "A test suite and interface you can use to implement a IPFS core interface.",
5-
"main": "test/index.js",
6-
"jsnext:main": "test/index.js",
5+
"main": "lib/index.js",
6+
"jsnext:main": "src/index.js",
77
"scripts": {
88
"test": "exit(0)",
99
"build": "aegir-build node",
@@ -42,4 +42,4 @@
4242
"David Dias <[email protected]>",
4343
"Friedel Ziegelmayer <[email protected]>"
4444
]
45-
}
45+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/files.js renamed to src/files.js

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,24 @@
22
'use strict'
33

44
const expect = require('chai').expect
5-
const DAGNode = require('ipfs-merkle-dag').DAGNode
65
const bs58 = require('bs58')
7-
const bl = require('bl')
86
const Readable = require('readable-stream')
97
const path = require('path')
108
const isNode = require('detect-node')
9+
const fs = require('fs')
1110

1211
module.exports = (common) => {
1312
describe('.files/add', () => {
14-
let testfile
15-
let testfileBig
13+
let smallFile
14+
let bigFile
1615
let ipfs
1716

1817
before((done) => {
19-
// load test data
20-
if (isNode) {
21-
const fs = require('fs')
18+
const sfPath = path.join(__dirname, './data/testfile.txt')
19+
const bfPath = path.join(__dirname, './data/15mb.random')
2220

23-
const testfilePath = path.join(__dirname, './data/testfile.txt')
24-
testfile = fs.readFileSync(testfilePath)
25-
26-
const testfileBigPath = path.join(__dirname, './data/15mb.random')
27-
testfileBig = fs.createReadStream(testfileBigPath, { bufferSize: 128 })
28-
} else {
29-
testfile = require('raw!./data/testfile.txt')
30-
}
21+
smallFile = fs.readFileSync(sfPath)
22+
bigFile = fs.readFileSync(bfPath)
3123

3224
common.setup((err, _ipfs) => {
3325
expect(err).to.not.exist
@@ -66,7 +58,7 @@ module.exports = (common) => {
6658

6759
const file = {
6860
path: 'testfile.txt',
69-
content: new Buffer(testfile)
61+
content: smallFile
7062
}
7163

7264
ipfs.files.add([file], (err, res) => {
@@ -82,8 +74,7 @@ module.exports = (common) => {
8274
})
8375

8476
it('buffer', (done) => {
85-
let buf = new Buffer(testfile)
86-
ipfs.files.add(buf, (err, res) => {
77+
ipfs.files.add(smallFile, (err, res) => {
8778
expect(err).to.not.exist
8879

8980
expect(res).to.have.length(1)
@@ -96,11 +87,7 @@ module.exports = (common) => {
9687
})
9788

9889
it('BIG buffer', (done) => {
99-
if (!isNode) {
100-
return done()
101-
}
102-
103-
ipfs.files.add(testfileBig, (err, res) => {
90+
ipfs.files.add(bigFile, (err, res) => {
10491
expect(err).to.not.exist
10592

10693
expect(res).to.have.length(1)
@@ -113,8 +100,9 @@ module.exports = (common) => {
113100
})
114101

115102
it('add a nested dir as array', (done) => {
116-
if (!isNode) return done()
117-
const fs = require('fs')
103+
if (!isNode) {
104+
return done()
105+
}
118106
const base = path.join(__dirname, 'data/test-folder')
119107
const content = (name) => ({
120108
path: `test-folder/${name}`,
@@ -149,8 +137,7 @@ module.exports = (common) => {
149137

150138
describe('promise', () => {
151139
it('buffer', () => {
152-
let buf = new Buffer(testfile)
153-
return ipfs.files.add(buf)
140+
return ipfs.files.add(smallFile)
154141
.then((res) => {
155142
const added = res[0] != null ? res[0] : res
156143
const mh = bs58.encode(added.node.multihash()).toString()
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)