Skip to content

Commit

Permalink
fix: cliv2 unsupported combination version + —json-file-output
Browse files Browse the repository at this point in the history
* re-enable disabled test for cliv2

Signed-off-by: Peter Schäfer <101886095+PeterSchafer@users.noreply.github.com>

fix: run formatter to avoid linter error

Signed-off-by: Peter Schäfer <101886095+PeterSchafer@users.noreply.github.com>
  • Loading branch information
PeterSchafer committed May 4, 2022
1 parent c9ac9c2 commit 493dba5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 11 additions & 1 deletion cliv2/internal/cliv2/cliv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ func (c *CLI) printVersion() {
fmt.Println(c.GetFullVersion())
}

func (c *CLI) commandVersion(passthroughArgs []string) int {
if utils.Contains(passthroughArgs, "--json-file-output") {
fmt.Println("The following option combination is not currently supported: version + json-file-output")
return SNYK_EXIT_CODE_ERROR
} else {
c.printVersion()
return SNYK_EXIT_CODE_OK
}
}

func determineHandler(passthroughArgs []string) Handler {
result := V1_DEFAULT

Expand Down Expand Up @@ -205,7 +215,7 @@ func (c *CLI) Execute(wrapperProxyPort int, fullPathToCert string, passthroughAr

switch {
case handler == V2_VERSION:
c.printVersion()
returnCode = c.commandVersion(passthroughArgs)
default:
returnCode = c.executeV1Default(wrapperProxyPort, fullPathToCert, passthroughArgs)
}
Expand Down
8 changes: 0 additions & 8 deletions test/jest/acceptance/cli-args.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { UnsupportedOptionCombinationError } from '../../../src/lib/errors/unsup
import { runSnykCLI } from '../util/runSnykCLI';
import { fakeServer } from '../../acceptance/fake-server';
import { createProject } from '../util/createProject';
import { isCLIV2 } from '../util/isCLIV2';

const isWindows =
require('os-name')()
Expand All @@ -13,13 +12,6 @@ const isWindows =
jest.setTimeout(1000 * 60 * 5);

describe('cli args', () => {
if (isCLIV2()) {
// eslint-disable-next-line jest/no-focused-tests
it.only('CLIv2 not yet supported', () => {
console.warn('Skipping test as CLIv2 does not support it yet.');
});
}

let server;
let env: Record<string, string>;

Expand Down

0 comments on commit 493dba5

Please sign in to comment.