diff --git a/CHANGELOG.md b/CHANGELOG.md index 29437e6..010db97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), Nothing yet. +## [3.0.3] - 2020-04-07 + +### Fixed + + - Improve optional argument handling in `ready()` method. + ## [3.0.2] - 2020-04-06 ### Changed diff --git a/index.js b/index.js index 9f49467..9f873f4 100644 --- a/index.js +++ b/index.js @@ -29,12 +29,17 @@ class Pebble { * @returns {Promise} Promise to return spawned child process. */ static async ready (args = [], env = { PEBBLE_VA_NOSLEEP: 1, PEBBLE_WFE_NONCEREJECT: 0 }) { - if (this.#pebbleProcess !== null) { // Existing process exists, return that. return this.#pebbleProcess } + if (arguments.length === 1 && Object.prototype.toString.call(args) === '[object Object]') { + // env was passed as the first (and only) argument + env = args + args = [] + } + // Spawn expects argument to be an array. Automatically convert a space-delimited arguments string to one. if (typeof args === 'string') { args = args.split(' ') diff --git a/package.json b/package.json index 302b89e..f9e677c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@small-tech/node-pebble", - "version": "3.0.2", + "version": "3.0.3", "description": "A Node.js wrapper for Let’s Encrypt’s Pebble (“a small RFC 8555 ACME test server not suited for a production certificate authority”).", "main": "index.js", "os": [