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(semver): resolve boolean arguments correctly #361

Merged
merged 1 commit into from
Oct 25, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ describe(executePostTargets.name, () => {
});
});

fit('should forward and resolve options', (done) => {
it('should forward and resolve options', (done) => {
mockReadTargetOptions.mockReturnValueOnce({
optionA: 'optionA',
version: '${version}',
dryRun: '${dryRun}',
numeric: '${num}',
falseyValue: '${falseyValue}',
});
mockReadTargetOptions.mockReturnValueOnce({
optionB: 'optionB',
Expand All @@ -135,6 +136,7 @@ describe(executePostTargets.name, () => {
version: '2.0.0',
dryRun: true,
num: 42,
falseyValue: false
};

executePostTargets({
Expand All @@ -148,6 +150,7 @@ describe(executePostTargets.name, () => {
version: '2.0.0',
dryRun: true,
numeric: 42,
falseyValue: false,
});
expect(mockRunExecutor.mock.calls[1][1]).toEqual({
optionB: 'optionB',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe(resolveInterpolation.name, () => {
).toBe('test string with 42 and true');
});

it('should resolve boolean', () => {
it('should resolve true boolean', () => {
expect(
resolveInterpolation(
'${bool}',
Expand All @@ -48,6 +48,15 @@ describe(resolveInterpolation.name, () => {
).toBe(true);
});

it('should resolve false boolean', () => {
expect(
resolveInterpolation(
'${bool}',
{ bool: false }
)
).toBe(false);
});

it('should resolve number', () => {
expect(
resolveInterpolation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function resolveInterpolation(
);

if (_isBool(resolvedValue)) {
return !!resolvedValue;
return resolvedValue === "true";
}

if (_isNumeric(resolvedValue)) {
Expand Down