Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cliv2 unsupported combination version + —json-file-output #3200

Merged
merged 1 commit into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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