pact-foundation / pact-js-core

Core binaries for pact-js, a Contract Testing Framework. NOTE: If you are looking to do Pact contract testing in node, you almost certainly want pact-js, not pact-node.
https://docs.pact.io
MIT License
150 stars 79 forks source link

CLI parameters with spaces broken since v14.3.5 #506

Closed gruntster closed 5 months ago

gruntster commented 5 months ago

Software versions

Issue Checklist

Please confirm the following:

Expected behaviour

CLIs handle quoted parameters with spaces, e.g. "my pact.json", as a single parameter.

Actual behaviour

Since v14.3.5, CLIs now treat quoted parameters as individual parameters, e.g. "my pact.json" is treated as two parameters my pact.json.

Steps to reproduce

An easy way to reproduce the issue is to run a CLI from v14.3.5 or v14.3.6 using npx. e.g. npx --package=@pact-foundation/pact-core@14.3.5 -c 'pact-broker publish "my pact.json" --consumer-app-version 1'

The error output highlights that the filename (in bold) has been truncated at the space.

Specified pact file 'my' does not exist.

Compared to running the same command with v14.3.4. npx --package=@pact-foundation/pact-core@14.3.4 -c 'pact-broker publish "my pact.json" --consumer-app-version 1'

Specified pact file 'my pact.json' does not exist.

YOU54F commented 5 months ago

This may have been introduced by #504 as that was the only change between v14.3.4 and v14.3.5

See release note

https://github.com/pact-foundation/pact-js-core/releases/tag/v14.3.5

YOU54F commented 5 months ago

Thanks for the repro, I've tested out a fix

npx --package=@you54f/pact-core@15.0.1 -c 'pact-broker publish "my pact.json" --consumer-app-version=1'

it doesn't set shell unless its windows, and if shell value is set, it escapes arguments based on the detected shell

https://github.com/YOU54F/pact-js-core/pull/45/files

will get a pr raised against this repo shortly

YOU54F commented 5 months ago

Fix released in 14.3.7

https://github.com/pact-foundation/pact-js-core/releases/tag/v14.3.7