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

Commit 732f063

Browse files
author
Alan Shaw
committed
fix: more fix
License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent fee0eed commit 732f063

File tree

5 files changed

+40
-64
lines changed

5 files changed

+40
-64
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"is-stream": "^2.0.0",
6969
"iso-stream-http": "~0.1.2",
7070
"iso-url": "~0.4.6",
71-
"it-glob": "0.0.3",
71+
"it-glob": "0.0.4",
7272
"it-to-stream": "^0.1.1",
7373
"iterable-ndjson": "^1.1.0",
7474
"just-kebab-case": "^1.1.0",

src/add-from-fs/glob-source.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async function * toGlobSource ({ path, type, prefix }, options) {
4646

4747
if (type === 'file') {
4848
yield {
49-
path: baseName.replace(prefix, ''),
49+
path: baseName,
5050
content: fs.createReadStream(
5151
Path.isAbsolute(path) ? path : Path.join(process.cwd(), path)
5252
)
@@ -71,8 +71,8 @@ async function * toGlobSource ({ path, type, prefix }, options) {
7171

7272
for await (const p of glob(path, '**/*', globOptions)) {
7373
yield {
74-
path: toPosix(p.replace(prefix, '')),
75-
content: fs.createReadStream(p)
74+
path: toPosix(Path.join(baseName, p)),
75+
content: fs.createReadStream(Path.join(path, p))
7676
}
7777
}
7878
}

src/files-regular/index.js

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,42 @@ const { collectify, pullify, streamify } = require('../lib/converters')
66

77
module.exports = (arg) => {
88
const send = moduleConfig(arg)
9+
const add = require('../add')(arg)
10+
const addFromFs = require('../add-from-fs')(arg)
11+
const addFromURL = require('../add-from-url')(arg)
912

1013
return {
11-
add: (_, config) => {
12-
const add = collectify(require('../add')(config))
13-
return (input, options, callback) => {
14-
if (typeof options === 'function') {
15-
callback = options
16-
options = {}
17-
}
18-
return nodeify(add(input, options), callback)
14+
add: (input, options, callback) => {
15+
if (typeof options === 'function') {
16+
callback = options
17+
options = {}
1918
}
19+
return nodeify(collectify(add)(input, options), callback)
2020
},
21-
addReadableStream: (_, config) => {
22-
const add = require('../add')(config)
23-
return streamify.transform(add)
24-
},
25-
addPullStream: (_, config) => {
26-
const add = require('../add')(config)
27-
return pullify.transform(add)
28-
},
29-
addFromFs: (_, config) => {
30-
const addFromFs = collectify(require('../add-from-fs')(config))
31-
return (path, options, callback) => {
32-
if (typeof options === 'function') {
33-
callback = options
34-
options = {}
35-
}
36-
return nodeify(addFromFs(path, options), callback)
21+
addReadableStream: streamify.transform(add),
22+
addPullStream: pullify.transform(add),
23+
addFromFs: (path, options, callback) => {
24+
if (typeof options === 'function') {
25+
callback = options
26+
options = {}
3727
}
28+
return nodeify(collectify(addFromFs)(path, options), callback)
3829
},
39-
addFromURL: (_, config) => {
40-
const addFromURL = collectify(require('../add-from-url')(config))
41-
return (url, options, callback) => {
42-
if (typeof options === 'function') {
43-
callback = options
44-
options = {}
45-
}
46-
return nodeify(addFromURL(url, options), callback)
30+
addFromURL: (url, options, callback) => {
31+
if (typeof options === 'function') {
32+
callback = options
33+
options = {}
4734
}
35+
return nodeify(collectify(addFromURL)(url, options), callback)
4836
},
49-
addFromStream: (_, config) => {
50-
const add = collectify(require('../add')(config))
51-
return (input, options, callback) => {
52-
if (typeof options === 'function') {
53-
callback = options
54-
options = {}
55-
}
56-
return nodeify(add(input, options), callback)
37+
addFromStream: (input, options, callback) => {
38+
if (typeof options === 'function') {
39+
callback = options
40+
options = {}
5741
}
42+
return nodeify(collectify(add)(input, options), callback)
5843
},
59-
_addAsyncIterator: (_, config) => require('../add')(config),
44+
_addAsyncIterator: add,
6045
cat: require('../files-regular/cat')(send),
6146
catReadableStream: require('../files-regular/cat-readable-stream')(send),
6247
catPullStream: require('../files-regular/cat-pull-stream')(send),

src/utils/load-commands.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
'use strict'
22

3-
function requireCommands () {
4-
return {
5-
// Files Regular (not MFS)
6-
...require('../files-regular'),
3+
function requireCommands (send, config) {
4+
const cmds = {
5+
...require('../files-regular')(config),
6+
getEndpointConfig: require('../get-endpoint-config')(config)
7+
}
78

9+
const subCmds = {
810
// Files MFS (Mutable Filesystem)
911
files: require('../files-mfs'),
1012

@@ -42,21 +44,14 @@ function requireCommands () {
4244
stats: require('../stats'),
4345
update: require('../update'),
4446
version: require('../version'),
45-
resolve: require('../resolve'),
46-
// ipfs-http-client instance
47-
getEndpointConfig: (send, config) => require('../get-endpoint-config')(config)
47+
resolve: require('../resolve')
4848
}
49-
}
50-
51-
function loadCommands (send, config) {
52-
const files = requireCommands()
53-
const cmds = {}
5449

55-
Object.keys(files).forEach((file) => {
56-
cmds[file] = files[file](send, config)
50+
Object.keys(subCmds).forEach((file) => {
51+
cmds[file] = subCmds[file](send, config)
5752
})
5853

5954
return cmds
6055
}
6156

62-
module.exports = loadCommands
57+
module.exports = requireCommands

test/interface.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ describe('interface-ipfs-core tests', () => {
131131
name: 'addFromFs',
132132
reason: 'Not designed to run in the browser'
133133
},
134-
{
135-
name: 'should ignore a directory from the file system',
136-
reason: 'FIXME bug in it-glob'
137-
},
138134
// .addFromURL
139135
isNode ? null : {
140136
name: 'addFromURL',

0 commit comments

Comments
 (0)