diff --git a/.travis.yml b/.travis.yml index e1d6320be4..dd9e44efb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: node_js node_js: - 4 - 5 + - stable # Make sure we have new NPM. before_install: diff --git a/package.json b/package.json index ecf361e729..194d40c0dd 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "bs58": "^3.0.0", "debug": "^2.2.0", "fs-blob-store": "^5.2.1", + "glob": "^7.0.3", "hapi": "^13.3.0", "ipfs-api": "^3.0.1", "ipfs-block": "^0.3.0", diff --git a/src/cli/commands/commands.js b/src/cli/commands/commands.js index 86bf059b73..91294b1414 100644 --- a/src/cli/commands/commands.js +++ b/src/cli/commands/commands.js @@ -2,21 +2,26 @@ const Command = require('ronin').Command const path = require('path') -const ronin = require('ronin') +const glob = require('glob').sync module.exports = Command.extend({ desc: 'List all available commands', - run: (name) => { - const cli = ronin(path.resolve(__dirname, '..')) + run (name) { + const basePath = path.resolve(__dirname, '..') - cli.setupCommands() + // modeled after https://github.com/vdemedes/ronin/blob/master/lib/program.js#L78 + const files = glob(path.join(basePath, 'commands', '**', '*.js')) + const cmds = files.map((p) => { + return p.replace(/\//g, path.sep) + .replace(/^./, ($1) => $1.toUpperCase()) + .replace(path.join(basePath, 'commands'), '') + .replace(path.sep, '') + .split(path.sep) + .join(' ') + .replace('.js', '') + }).sort().map((cmd) => `ipfs ${cmd}`) - const commands = [''] - .concat(Object.keys(cli.commands)) - .map((command) => 'ipfs ' + command) - .join('\n') - - console.log(commands) + console.log(['ipfs'].concat(cmds).join('\n')) } })