Skip to content

Commit

Permalink
Merge pull request #58 from LibreSign/feature/validate-if-jq-exists
Browse files Browse the repository at this point in the history
Validate if jq exists
  • Loading branch information
vitormattos authored Mar 20, 2024
2 parents a78f0b4 + fd2ed8f commit f194953
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
3 changes: 2 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.22.2@d768d914152dbbf3486c36398802f74e80cfde48">
<files psalm-version="5.23.1@8471a896ccea3526b26d082f4461eeea467f10a4">
<file src="src/NextcloudApiContext.php">
<ForbiddenCode>
<code><![CDATA[`which jq`]]></code>
<code><![CDATA[`which jq`]]></code>
</ForbiddenCode>
</file>
</files>
5 changes: 2 additions & 3 deletions src/NextcloudApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,13 @@ private function testAndGetActualValue(array $value, string $json): string {
* @return mixed
*/
private function evalJsonQuery(string $jsonQuery, string $target) {
Assert::assertNotEmpty(`which jq`, 'Is necessary install the jq command to use jq');
$jq = \JsonQueryWrapper\JsonQueryFactory::createWith($target);
return $jq->run($jsonQuery);
}

private function validateAsJsonQuery(string $expected, string $actual): void {
if (!`which jq`) {
throw new \InvalidArgumentException('Is necessary install the jq command to use jq');
}
Assert::assertNotEmpty(`which jq`, 'Is necessary install the jq command to use jq');
$jq = \JsonQueryWrapper\JsonQueryFactory::createWith($actual);
$result = $jq->run($expected);
Assert::assertTrue($result, 'The jq "' . $expected . '" do not match with: ' . $actual);
Expand Down
24 changes: 12 additions & 12 deletions vendor-bin/coding-standard/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions vendor-bin/psalm/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f194953

Please sign in to comment.