From 605e7df1a3cfa7e88bb58dbc2992f9b673374fd1 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Wed, 23 Oct 2024 10:59:19 -0400 Subject: [PATCH] #240: fixed regression causing empty tooling options to throw an error --- CHANGELOG.md | 1 + examples/tooling/.lando.yml | 4 ++++ examples/tooling/README.md | 3 +++ lib/cli.js | 3 +++ 4 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96fe957d8..272a00fbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Fixed bug causing https proxy routes to be assigned when they shouldnt be * Fixed bug causing cache from repopulating old proxy addresses that have been removed [#209](https://github.com/lando/core/issues/209) * Fixed bug in `v4` auto `entrypoint` and `command` population +* Fixed regression causing empty tooling `options` to throw an error [#240](https://github.com/lando/core/issues/240) ## v3.23.0-beta.4 - [October 22, 2024](https://github.com/lando/core/releases/tag/v3.23.0-beta.4) diff --git a/examples/tooling/.lando.yml b/examples/tooling/.lando.yml index 06d5d5d49..1d945dcd6 100644 --- a/examples/tooling/.lando.yml +++ b/examples/tooling/.lando.yml @@ -201,6 +201,10 @@ tooling: cmd: pwd service: web dir: /tmp + emptyopter: + cmd: pwd + service: web + options: pwd: cmd: pwd service: :service diff --git a/examples/tooling/README.md b/examples/tooling/README.md index 354686e52..f4fd5fa7c 100644 --- a/examples/tooling/README.md +++ b/examples/tooling/README.md @@ -158,6 +158,9 @@ lando everything --help | grep "lando everything \[arg1\] \[arg2\] MORETHINGS" # Should allow for example pasthru in task definition lando everything --help | grep "lando this is just for testing" + +# Should be able to run even if options are empty +lando emptyopter ``` ## Destroy tests diff --git a/lib/cli.js b/lib/cli.js index a37842663..60098cc6a 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -460,6 +460,9 @@ module.exports = class Cli { // Return our yarg command return {command, describe, handler, builder: yargs => { + // ensure options is an object if it isnt + if (!_.isPlainObject(options)) options = {}; + // if we have options then let is sort and add them if (Object.keys(options).length > 0) { for (const [option, config] of Object.entries(formatters.sortOptions(options))) {