-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add --json-file-output option for snyk test
- Loading branch information
Showing
18 changed files
with
900 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
export class CommandResult { | ||
result: string; | ||
constructor(result: string) { | ||
this.result = result; | ||
} | ||
|
||
public toString(): string { | ||
return this.result; | ||
} | ||
|
||
public getDisplayResults() { | ||
return this.result; | ||
} | ||
} | ||
|
||
export abstract class TestCommandResult extends CommandResult { | ||
protected jsonResult = ''; | ||
public getJsonResult(): string { | ||
return this.jsonResult; | ||
} | ||
|
||
public static createHumanReadableTestCommandResult( | ||
humanReadableResult: string, | ||
jsonResult: string, | ||
): HumanReadableTestCommandResult { | ||
return new HumanReadableTestCommandResult(humanReadableResult, jsonResult); | ||
} | ||
|
||
public static createJsonTestCommandResult( | ||
jsonResult: string, | ||
): JsonTestCommandResult { | ||
return new JsonTestCommandResult(jsonResult); | ||
} | ||
} | ||
|
||
class HumanReadableTestCommandResult extends TestCommandResult { | ||
protected jsonResult = ''; | ||
|
||
constructor(humanReadableResult: string, jsonResult: string) { | ||
super(humanReadableResult); | ||
this.jsonResult = jsonResult; | ||
} | ||
|
||
public getJsonResult(): string { | ||
return this.jsonResult; | ||
} | ||
} | ||
|
||
class JsonTestCommandResult extends TestCommandResult { | ||
constructor(jsonResult: string) { | ||
super(jsonResult); | ||
} | ||
|
||
public getJsonResult(): string { | ||
return this.result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CustomError } from './custom-error'; | ||
|
||
export class JsonFileOutputBadInputError extends CustomError { | ||
private static ERROR_CODE = 422; | ||
private static ERROR_MESSAGE = | ||
'Empty --json-file-output argument. Did you mean --file=path/to/output-file.json ?'; | ||
|
||
constructor() { | ||
super(JsonFileOutputBadInputError.ERROR_MESSAGE); | ||
this.code = JsonFileOutputBadInputError.ERROR_CODE; | ||
this.userMessage = JsonFileOutputBadInputError.ERROR_MESSAGE; | ||
} | ||
} |
Oops, something went wrong.