Skip to content

Commit

Permalink
Improve optional argument handling in ready() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
aral committed Apr 7, 2020
1 parent c1f867b commit 1c38ea2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ class Pebble {
* @returns {Promise<ChildProcess>} 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(' ')
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": "@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": [
Expand Down

0 comments on commit 1c38ea2

Please sign in to comment.