Skip to content

Commit

Permalink
Fixed issue when help is requested and not displayed (silent unit tes…
Browse files Browse the repository at this point in the history
…t failure)
  • Loading branch information
coreybutler committed May 1, 2020
1 parent a7ea611 commit 99d7fa5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@author.io/shell",
"version": "1.3.14",
"version": "1.3.15",
"description": "A micro-framework for creating CLI-like experiences. This supports Node.js and browsers.",
"main": "src/index.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export default class Command extends Base {
}

async run (input, callback) {
const fn = (this.#fn || this.defaultHandler).bind(this)
let fn = (this.#fn || this.defaultHandler).bind(this)
const data = typeof input === 'string' ? this.parse(input) : input

arguments[0] = this.deepParse(input)
Expand All @@ -414,6 +414,10 @@ export default class Command extends Base {
return this.middleware.run(arguments[0], async meta => await Command.reply(fn(meta, callback)))
}

if (arguments[0].help && arguments[0].help.requested) {
return Command.reply(fn(data, () => console.log(this.help)))
}

return Command.reply(fn(data, callback))
}

Expand Down
3 changes: 2 additions & 1 deletion test/unit/01-sanity/01-sanity.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'source-map-support/register.js'
import test from 'tape'
import { Command, Shell, Formatter } from '../../.node/index.js'
import fs from 'fs'
// import fs from 'fs'

test('Sanity Check - Shell', t => {
const shell = new Shell({
name: 'test'
Expand Down

0 comments on commit 99d7fa5

Please sign in to comment.