Skip to content

Commit

Permalink
Added default strings to prevent undefined customUsage and customHelp…
Browse files Browse the repository at this point in the history
… from causing errors in data serialization.
  • Loading branch information
coreybutler committed Apr 5, 2020
1 parent be79054 commit dc1bfa7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ shell.add(new Command({
}))

shell.use((data, next) => {
console.log('This middleware runs on very command.')
console.log('This middleware runs on every command.')
next()
})

Expand Down
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.2.0",
"version": "1.2.1",
"description": "A micro-framework for creating CLI-like experiences. This supports Node.js and browsers.",
"main": "src/index.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions src/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export default class Command {
}

get description () {
return this.#description || this.usage
return this.#description || this.usage || ''
}

get commandroot () {
Expand All @@ -223,8 +223,8 @@ export default class Command {
const a = Array.from(this.#aliases)
const msg = [`${this.commandroot}${a.length > 0 ? ' <' + a.join(', ') + '> ' : ''} [OPTIONS]`.trim()]

if (this.#description.trim().length > 0) {
msg.push('\n ' + this.#description.trim())
if ((this.#description || '').trim().length > 0) {
msg.push('\n ' + (this.#description || '').trim())
}
return msg.join('\n').trim()
}
Expand Down

0 comments on commit dc1bfa7

Please sign in to comment.