Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Fix EnvironmentVariableParser error messages to report the environment variable name instead of its value",
"type": "patch",
"packageName": "@rushstack/ts-command-line"
}
],
"packageName": "@rushstack/ts-command-line",
"email": "sshaurya914@gmail.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ export class EnvironmentVariableParser {
!parsedJson.every((x) => typeof x === 'string' || typeof x === 'boolean' || typeof x === 'number')
) {
throw new Error(
`The ${environmentValue} environment variable value must be a JSON ` +
`The ${envVarName} environment variable value must be a JSON ` +
` array containing only strings, numbers, and booleans.`
);
}
return parsedJson.map((x) => x.toString());
} catch (ex) {
throw new Error(
`The ${environmentValue} environment variable value looks like a JSON array` +
`The ${envVarName} environment variable value looks like a JSON array` +
` but failed to parse: ` +
(ex as Error).message
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ describe(CommandLineParameterBase.name, () => {
}

expect(error).toMatch(
/^The \[u environment variable value looks like a JSON array but failed to parse: Unexpected token /
/^The ENV_COLOR environment variable value looks like a JSON array but failed to parse: Unexpected token /
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Array [
]
`;

exports[`CommandLineParameterBase choice list raises an error if env var value is json containing non-scalars 1`] = `"The [{}] environment variable value looks like a JSON array but failed to parse: The [{}] environment variable value must be a JSON array containing only strings, numbers, and booleans."`;
exports[`CommandLineParameterBase choice list raises an error if env var value is json containing non-scalars 1`] = `"The ENV_COLOR environment variable value looks like a JSON array but failed to parse: The ENV_COLOR environment variable value must be a JSON array containing only strings, numbers, and booleans."`;

exports[`CommandLineParameterBase choice list raises an error if env var value is not a valid choice 1`] = `"Invalid value \\"oblong\\" for the environment variable ENV_COLOR. Valid choices are: \\"purple\\", \\"yellow\\", \\"pizza\\""`;

Expand Down
Loading