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

Commit 4c88152

Browse files
committed
feat: update CLI to use latest Files API
1 parent 6cb438e commit 4c88152

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

src/cli/bin.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const print = utils.print
1111
const mfs = require('ipfs-mfs/cli')
1212
const debug = require('debug')('ipfs:cli')
1313

14-
const pkg = readPkgUp.sync({cwd: __dirname}).pkg
14+
const pkg = readPkgUp.sync({ cwd: __dirname }).pkg
1515
updateNotifier({
1616
pkg,
1717
updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week
@@ -74,20 +74,9 @@ if (args[0] === 'daemon' || args[0] === 'init') {
7474
throw err
7575
}
7676

77-
// add mfs commands
77+
// add MFS (Files API) commands
7878
mfs(cli)
7979

80-
// NOTE: This creates an alias of
81-
// `jsipfs files {add, get, cat}` to `jsipfs {add, get, cat}`.
82-
// This will stay until https://github.com/ipfs/specs/issues/98 is resolved.
83-
const addCmd = require('./commands/files/add')
84-
const catCmd = require('./commands/files/cat')
85-
const getCmd = require('./commands/files/get')
86-
const aliases = [addCmd, catCmd, getCmd]
87-
aliases.forEach((alias) => {
88-
cli.command(alias)
89-
})
90-
9180
cli
9281
.commandDir('commands')
9382
.help()
@@ -118,7 +107,7 @@ if (args[0] === 'daemon' || args[0] === 'init') {
118107
exitCode = 1
119108
})
120109
.then(() => cleanup())
121-
.catch(() => {})
110+
.catch((e) => {})
122111
.then(() => {
123112
if (exitCode !== 0) {
124113
process.exit(exitCode)

src/cli/commands/files/add.js renamed to src/cli/commands/add.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const getFolderSize = require('get-folder-size')
1111
const byteman = require('byteman')
1212
const waterfall = require('async/waterfall')
1313
const mh = require('multihashes')
14-
const utils = require('../../utils')
15-
const print = require('../../utils').print
16-
const createProgressBar = require('../../utils').createProgressBar
14+
const utils = require('../utils')
15+
const print = require('../utils').print
16+
const createProgressBar = require('../utils').createProgressBar
1717

1818
function checkPath (inPath, recursive) {
1919
// This function is to check for the following possible inputs

src/cli/commands/files/cat.js renamed to src/cli/commands/cat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = {
2929
length: argv.length
3030
}
3131

32-
const stream = argv.ipfs.files.catReadableStream(path, options)
32+
const stream = argv.ipfs.catReadableStream(path, options)
3333

3434
stream.once('error', (err) => {
3535
throw err

src/cli/commands/files/get.js renamed to src/cli/commands/get.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const path = require('path')
55
const mkdirp = require('mkdirp')
66
const pull = require('pull-stream')
77
const toPull = require('stream-to-pull-stream')
8-
const print = require('../../utils').print
8+
const print = require('../utils').print
99

1010
function checkArgs (hash, outPath) {
1111
// format the output directory
@@ -63,7 +63,7 @@ module.exports = {
6363

6464
const dir = checkArgs(ipfsPath, argv.output)
6565

66-
const stream = argv.ipfs.files.getReadableStream(ipfsPath)
66+
const stream = argv.ipfs.getReadableStream(ipfsPath)
6767

6868
stream.once('error', (err) => {
6969
if (err) { throw err }

0 commit comments

Comments
 (0)