From c2284e12c2e5c37adbb1af8c036987f80b419633 Mon Sep 17 00:00:00 2001 From: Joey Guerra Date: Sun, 5 Nov 2023 21:05:24 -0600 Subject: [PATCH 1/3] chore: Update main.html --- docs/layouts/main.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/layouts/main.html b/docs/layouts/main.html index 3e999d2bf..74cc2f1f3 100644 --- a/docs/layouts/main.html +++ b/docs/layouts/main.html @@ -34,8 +34,8 @@

A Customizable,
Life Embetterment Robot

{{> @partial-block }} - \ No newline at end of file + From 5738ea1b30317c1358912294ddb77dfca50dd6be Mon Sep 17 00:00:00 2001 From: Joey Guerra Date: Sun, 5 Nov 2023 21:06:01 -0600 Subject: [PATCH 2/3] chore: Update docs.html --- docs/layouts/docs.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/layouts/docs.html b/docs/layouts/docs.html index 48a27882b..5a5e8e34e 100644 --- a/docs/layouts/docs.html +++ b/docs/layouts/docs.html @@ -61,8 +61,8 @@

Hubot Documentation

- +

Built with <3 by friends of Hubot

- \ No newline at end of file + From 5641d4c728891b5d8ea419ca5635b77aaf396343 Mon Sep 17 00:00:00 2001 From: Joey Guerra Date: Wed, 8 Nov 2023 22:39:40 -0600 Subject: [PATCH 3/3] fix(hubot): hubot --help wasn't working (#1693) --- bin/hubot.js | 2 +- src/OptParse.js | 5 +++++ test/hubot_test.js | 30 +++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/bin/hubot.js b/bin/hubot.js index 6b42721b7..2f7ab841f 100755 --- a/bin/hubot.js +++ b/bin/hubot.js @@ -33,7 +33,7 @@ const options = { } const Parser = new OptParse(switches) -Parser.banner = 'Usage hubot [options]' +Parser.banner = 'Usage: hubot [options]' Parser.on('adapter', (opt, value) => { options.adapter = value diff --git a/src/OptParse.js b/src/OptParse.js index f5b2add1a..6344150b6 100644 --- a/src/OptParse.js +++ b/src/OptParse.js @@ -34,6 +34,11 @@ class OptParse extends EventEmitter { } return options } + + toString () { + return `${this.banner} +${this.switches.map(([key, description]) => ` ${key}, ${description}`).join('\n')}` + } } module.exports = OptParse diff --git a/test/hubot_test.js b/test/hubot_test.js index 8b83646a8..479b23c0e 100644 --- a/test/hubot_test.js +++ b/test/hubot_test.js @@ -9,7 +9,7 @@ const { TextMessage, User } = require('../index.js') const path = require('node:path') describe('Running bin/hubot.js', () => { - it('should load adapter from HUBOT_FILE environment variable', async function () { + it('should load adapter from HUBOT_FILE environment variable', async () => { process.env.HUBOT_HTTPD = 'false' process.env.HUBOT_FILE = path.resolve(root, 'test', 'fixtures', 'MockAdapter.mjs') const hubot = require('../bin/hubot.js') @@ -31,4 +31,32 @@ describe('Running bin/hubot.js', () => { hubot.shutdown() } }) + const { spawn } = require('child_process') + + it('should output a help message when run with --help', (t, done) => { + const hubot = spawn('./bin/hubot', ['--help']) + const expected = `Usage: hubot [options] + -a, --adapter HUBOT_ADAPTER + -f, --file HUBOT_FILE + -c, --create HUBOT_CREATE + -d, --disable-httpd HUBOT_HTTPD + -h, --help + -l, --alias HUBOT_ALIAS + -n, --name HUBOT_NAME + -r, --require PATH + -t, --config-check + -v, --version +` + let actual = '' + hubot.stdout.on('data', (data) => { + actual += data.toString() + }) + hubot.stderr.on('data', (data) => { + actual += data.toString() + }) + hubot.on('close', (code) => { + assert.deepEqual(actual, expected) + done() + }) + }) })