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

Commit

Permalink
fix(CR): apply CR
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Aug 18, 2016
1 parent 17f95fb commit c0e66cb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ before_install:

script:
- npm run lint
- npm test
- npm run test:node
- npm run coverage

addons:
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,20 @@ Complete documentation for these methods is coming with: https://github.com/ipfs

#### Add files or entire directories from the FileSystem to IPFS

> `ipfs.util.fsAdd(path, option, callback)`
> `ipfs.util.addFromFs(path, option, callback)`
Reads path from disk (if directory add an options `{ recursive: true }` and adds it to IPFS.
Reads a file from `path` on the filesystem and adds it to IPFS. If `path` is a directory, use option `{ recursive: true }` to add the directory and all its sub-directories.

```JavaScript
ipfs.util.fsAdd(<dirpath>, { recursive: true }, (err, result) => {
ipfs.util.addFromFs('path/to/a/file', { recursive: true }, (err, result) => {
if (err) {
throw err
}
console.log(result)
})
```

`files` is an array of objects describing the files that were added, such as:
`result` is an array of objects describing the files that were added, such as:

```
[{
Expand All @@ -143,10 +143,10 @@ ipfs.util.fsAdd(<dirpath>, { recursive: true }, (err, result) => {

#### Add a file from a URL to IPFS

> `ipfs.util.urlAdd(url, callback)`
> `ipfs.util.addFromURL(url, callback)`
```JavaScript
ipfs.util.urlAdd('http://example.com/', (err, result) => {
ipfs.util.addFromURL('http://example.com/', (err, result) => {
if (err) {
throw err
}
Expand All @@ -157,12 +157,12 @@ ipfs.util.urlAdd('http://example.com/', (err, result) => {

#### Add a file from a stream to IPFS

> `ipfs.util.streamAdd(stream, callback)`
> `ipfs.util.addFromStream(stream, callback)`
This is very similar to `ipfs.files.add({path:'', content: stream})`. It is like the reverse of cat

```JavaScript
ipfs.util.streamAdd(<readable-stream>, (err, result) => {
ipfs.util.addFromStream(<readable-stream>, (err, result) => {
if (err) {
throw err
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"main": "lib/index.js",
"jsnext:main": "src/index.js",
"scripts": {
"test": "node --max_old_space_size=4096 node_modules/.bin/gulp test",
"test": "node --max_old_space_size=4096 node_modules/.bin/gulp test:node",
"test:node": "gulp test:node",
"test:browser": "node --max_old_space_size=4096 node_modules/.bin/gulp test:browser",
"lint": "aegir-lint",
"build": "gulp build",
"release": "gulp release",
"release-minor": "gulp release --type minor",
"release-major": "gulp release --type major",
"release": "node --max_old_space_size=4096 node_modules/.bin/gulp release",
"release-minor": "node --max_old_space_size=4096 node_modules/.bin/gulp release --type minor",
"release-major": "node --max_old_space_size=4096 node_modules/.bin/gulp release --type major",
"coverage": "gulp coverage",
"coverage-publish": "aegir-coverage publish"
},
Expand Down
6 changes: 3 additions & 3 deletions src/load-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ function requireCommands () {

cmds.util = function (send) {
const util = {
fsAdd: require('./api/util/fs-add')(send),
streamAdd: require('./api/add')(send),
urlAdd: require('./api/util/url-add')(send)
addFromFs: require('./api/util/fs-add')(send),
addFromStream: require('./api/add')(send),
addFromURL: require('./api/util/url-add')(send)
}
return util
}
Expand Down
8 changes: 4 additions & 4 deletions test/ipfs-api/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('.util', () => {
const rs = fs.createReadStream(tfpath)
rs.path = '' // clean the path for testing purposes

ipfs.util.streamAdd(rs, (err, result) => {
ipfs.util.addFromStream(rs, (err, result) => {
expect(err).to.not.exist
expect(result.length).to.equal(1)
done()
Expand All @@ -44,7 +44,7 @@ describe('.util', () => {

it('.fsAdd a directory', (done) => {
const filesPath = path.join(__dirname, '../data/test-folder')
ipfs.util.fsAdd(filesPath, { recursive: true }, (err, result) => {
ipfs.util.addFromFs(filesPath, { recursive: true }, (err, result) => {
expect(err).to.not.exist
expect(result.length).to.be.above(8)
done()
Expand All @@ -53,7 +53,7 @@ describe('.util', () => {

it('.fsAdd a file', (done) => {
const filePath = path.join(__dirname, '../data/testfile.txt')
ipfs.util.fsAdd(filePath, (err, result) => {
ipfs.util.addFromFs(filePath, (err, result) => {
expect(err).to.not.exist
expect(result.length).to.be.above(5)

Expand All @@ -62,7 +62,7 @@ describe('.util', () => {
})

it('.urlAdd', (done) => {
ipfs.util.urlAdd('http://example.com/', (err, result) => {
ipfs.util.addFromURL('http://example.com/', (err, result) => {
expect(err).to.not.exist
expect(result.length).to.equal(1)
done()
Expand Down

0 comments on commit c0e66cb

Please sign in to comment.