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

Commit bc0948b

Browse files
committed
fix adding empty dirs
1 parent 90a0e6d commit bc0948b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ Where `data` may be
7777
- a `Buffer` instance
7878
- a `Readable` stream
7979

80-
`callback` must follow `function (err, res) {}` signature, where `err` is an
81-
error if the operation was not successful. `res` will be an array of
80+
If no `content` is passed, then the path is treated as an empty directory
81+
82+
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` will be an array of:
8283

8384
```js
8485
{
@@ -90,6 +91,7 @@ error if the operation was not successful. `res` will be an array of
9091
If no `callback` is passed, a promise is returned.
9192

9293
Example:
94+
9395
```js
9496
var files = [
9597
{

src/files.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const expect = require('chai').expect
55
const bs58 = require('bs58')
66
const Readable = require('readable-stream')
77
const path = require('path')
8-
const isNode = require('detect-node')
98
const fs = require('fs')
9+
const isNode = require('detect-node')
1010

1111
module.exports = (common) => {
1212
describe('.files/add', () => {
@@ -53,8 +53,6 @@ module.exports = (common) => {
5353
})
5454

5555
it('buffer as tuple', (done) => {
56-
if (!isNode) return done()
57-
5856
const file = {
5957
path: 'testfile.txt',
6058
content: smallFile
@@ -101,15 +99,16 @@ module.exports = (common) => {
10199
it('add a nested dir as array', (done) => {
102100
if (!isNode) {
103101
return done()
102+
// can't run this test cause browserify
103+
// can't shim readFileSync in runtime
104104
}
105105
const base = path.join(__dirname, 'data/test-folder')
106106
const content = (name) => ({
107107
path: `test-folder/${name}`,
108108
content: fs.readFileSync(path.join(base, name))
109109
})
110110
const emptyDir = (name) => ({
111-
path: `test-folder/${name}`,
112-
dir: true
111+
path: `test-folder/${name}`
113112
})
114113
const dirs = [
115114
content('pp.txt'),

0 commit comments

Comments
 (0)