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

Commit 5c26fae

Browse files
committed
Merge pull request #188 from ipfs/fix/node-6
fix(cli): self host cmds listing
2 parents 1251dea + a415dc1 commit 5c26fae

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: node_js
33
node_js:
44
- 4
55
- 5
6+
- stable
67

78
# Make sure we have new NPM.
89
before_install:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"bs58": "^3.0.0",
6161
"debug": "^2.2.0",
6262
"fs-blob-store": "^5.2.1",
63+
"glob": "^7.0.3",
6364
"hapi": "^13.3.0",
6465
"ipfs-api": "^3.0.1",
6566
"ipfs-block": "^0.3.0",

src/cli/commands/commands.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@
22

33
const Command = require('ronin').Command
44
const path = require('path')
5-
const ronin = require('ronin')
5+
const glob = require('glob').sync
66

77
module.exports = Command.extend({
88
desc: 'List all available commands',
99

10-
run: (name) => {
11-
const cli = ronin(path.resolve(__dirname, '..'))
10+
run (name) {
11+
const basePath = path.resolve(__dirname, '..')
1212

13-
cli.setupCommands()
13+
// modeled after https://github.com/vdemedes/ronin/blob/master/lib/program.js#L78
14+
const files = glob(path.join(basePath, 'commands', '**', '*.js'))
15+
const cmds = files.map((p) => {
16+
return p.replace(/\//g, path.sep)
17+
.replace(/^./, ($1) => $1.toUpperCase())
18+
.replace(path.join(basePath, 'commands'), '')
19+
.replace(path.sep, '')
20+
.split(path.sep)
21+
.join(' ')
22+
.replace('.js', '')
23+
}).sort().map((cmd) => `ipfs ${cmd}`)
1424

15-
const commands = ['']
16-
.concat(Object.keys(cli.commands))
17-
.map((command) => 'ipfs ' + command)
18-
.join('\n')
19-
20-
console.log(commands)
25+
console.log(['ipfs'].concat(cmds).join('\n'))
2126
}
2227
})

0 commit comments

Comments
 (0)