Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Bad command-line for debugDiagnosticSeverity does not crashes Prepack…
Browse files Browse the repository at this point in the history
… anymore (#2545)

Summary:
This can be a possible fix for #2509

I have removed the `invariant` method call and added a value check as used for the _invariantMode_ option.

`node lib/prepack-cli.js --debugDiagnosticSeverity foo`

will now generate

`Unsupported debugDiagnosticSeverity: foo`
Pull Request resolved: #2545

Differential Revision: D9800485

Pulled By: hermanventer

fbshipit-source-id: edc24b4a812b4e32f9c48e05a0799bf4af431991
  • Loading branch information
giftkugel authored and facebook-github-bot committed Sep 12, 2018
1 parent 1e1c03c commit 0b43479
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const InvariantModeValues = [
"nativeLoggingHook+2",
"nativeLoggingHook+3",
];
export const DiagnosticSeverityValues = ["FatalError", "RecoverableError", "Warning", "Information"];

export type ReactOutputTypes = "create-element" | "jsx" | "bytecode";
export const ReactOutputValues = ["create-element", "jsx", "bytecode"];
Expand Down
5 changes: 5 additions & 0 deletions src/prepack-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
ReactOutputValues,
type InvariantModeTypes,
InvariantModeValues,
DiagnosticSeverityValues,
} from "./options.js";
import { type SerializedResult } from "./serializer/types.js";
import { TextPrinter } from "./utils/TextPrinter.js";
Expand Down Expand Up @@ -299,6 +300,10 @@ function run(
break;
case "debugDiagnosticSeverity":
arg = args.shift();
if (!DiagnosticSeverityValues.includes(arg)) {
console.error(`Unsupported debugDiagnosticSeverity: ${arg}`);
process.exit(1);
}
invariant(
arg === "FatalError" || arg === "RecoverableError" || arg === "Warning" || arg === "Information",
`Invalid debugger diagnostic severity: ${arg}`
Expand Down

0 comments on commit 0b43479

Please sign in to comment.