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

Commit

Permalink
feat: update CLI to use latest Files API
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Oct 26, 2018
1 parent 6cb438e commit 4c88152
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
17 changes: 3 additions & 14 deletions src/cli/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const print = utils.print
const mfs = require('ipfs-mfs/cli')
const debug = require('debug')('ipfs:cli')

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

// add mfs commands
// add MFS (Files API) commands
mfs(cli)

// NOTE: This creates an alias of
// `jsipfs files {add, get, cat}` to `jsipfs {add, get, cat}`.
// This will stay until https://github.com/ipfs/specs/issues/98 is resolved.
const addCmd = require('./commands/files/add')
const catCmd = require('./commands/files/cat')
const getCmd = require('./commands/files/get')
const aliases = [addCmd, catCmd, getCmd]
aliases.forEach((alias) => {
cli.command(alias)
})

cli
.commandDir('commands')
.help()
Expand Down Expand Up @@ -118,7 +107,7 @@ if (args[0] === 'daemon' || args[0] === 'init') {
exitCode = 1
})
.then(() => cleanup())
.catch(() => {})
.catch((e) => {})
.then(() => {
if (exitCode !== 0) {
process.exit(exitCode)
Expand Down
6 changes: 3 additions & 3 deletions src/cli/commands/files/add.js → src/cli/commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const getFolderSize = require('get-folder-size')
const byteman = require('byteman')
const waterfall = require('async/waterfall')
const mh = require('multihashes')
const utils = require('../../utils')
const print = require('../../utils').print
const createProgressBar = require('../../utils').createProgressBar
const utils = require('../utils')
const print = require('../utils').print
const createProgressBar = require('../utils').createProgressBar

function checkPath (inPath, recursive) {
// This function is to check for the following possible inputs
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/files/cat.js → src/cli/commands/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
length: argv.length
}

const stream = argv.ipfs.files.catReadableStream(path, options)
const stream = argv.ipfs.catReadableStream(path, options)

stream.once('error', (err) => {
throw err
Expand Down
4 changes: 2 additions & 2 deletions src/cli/commands/files/get.js → src/cli/commands/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const path = require('path')
const mkdirp = require('mkdirp')
const pull = require('pull-stream')
const toPull = require('stream-to-pull-stream')
const print = require('../../utils').print
const print = require('../utils').print

function checkArgs (hash, outPath) {
// format the output directory
Expand Down Expand Up @@ -63,7 +63,7 @@ module.exports = {

const dir = checkArgs(ipfsPath, argv.output)

const stream = argv.ipfs.files.getReadableStream(ipfsPath)
const stream = argv.ipfs.getReadableStream(ipfsPath)

stream.once('error', (err) => {
if (err) { throw err }
Expand Down

0 comments on commit 4c88152

Please sign in to comment.