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

Commit

Permalink
fix: simplify ls
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
  • Loading branch information
Alan Shaw committed Nov 9, 2018
1 parent e7ddd79 commit 4b34b7c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cli/commands/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ module.exports = {
}
},

handler (argv) {
argv.ipfs.ls(argv.key, { recursive: argv.recursive, cidBase: argv.cidBase }, (err, links) => {
handler ({ ipfs, key, recursive, headers, cidBase }) {
ipfs.ls(key, { recursive, cidBase }, (err, links) => {
if (err) {
throw err
}

if (argv.headers) {
if (headers) {
links = [{ hash: 'Hash', size: 'Size', name: 'Name' }].concat(links)
}

const multihashWidth = Math.max.apply(null, links.map((file) => file.hash.length))
const sizeWidth = Math.max.apply(null, links.map((file) => String(file.size).length))

let pathParts = argv.key.split('/')
let pathParts = key.split('/')

if (argv.key.startsWith('/ipfs/')) {
if (key.startsWith('/ipfs/')) {
pathParts = pathParts.slice(2)
}

Expand Down

0 comments on commit 4b34b7c

Please sign in to comment.