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

Commit 4ce16b7

Browse files
committed
feat: push sorting out of core
License: MIT Signed-off-by: achingbrain <[email protected]>
1 parent 64dc0ec commit 4ce16b7

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/cli/ls.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = {
2727
sort: {
2828
alias: 's',
2929
type: 'boolean',
30-
default: false,
30+
default: true,
3131
coerce: asBoolean,
3232
describe: 'Sort entries by name'
3333
},
@@ -55,6 +55,13 @@ module.exports = {
5555
cidBase
5656
})
5757
.then(files => {
58+
// https://github.com./ipfs/go-ipfs/issues/5181
59+
if (sort) {
60+
return callback(null, files.sort((a, b) => {
61+
return a.name.localeCompare(b.name)
62+
}))
63+
}
64+
5865
if (long) {
5966
files.forEach(link => {
6067
print(`${link.name}\t${link.hash}\t${link.size}`)

src/core/ls.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,7 @@ module.exports = (context) => {
2222

2323
pull(
2424
lsPullStream(context)(path, options),
25-
collect((err, files) => {
26-
if (err) {
27-
return callback(err)
28-
}
29-
30-
// https://github.com./ipfs/go-ipfs/issues/5181
31-
if (options.sort) {
32-
return callback(null, files.sort((a, b) => {
33-
return a.name.localeCompare(b.name)
34-
}))
35-
}
36-
37-
return callback(null, files)
38-
})
25+
collect(callback)
3926
)
4027
}
4128
}

0 commit comments

Comments
 (0)