Skip to content

Commit

Permalink
Merge pull request #1 from GarethDJohn/fix-issue-353
Browse files Browse the repository at this point in the history
fix(semver): resolve boolean arguments correctly
  • Loading branch information
garethdjohn authored Oct 25, 2021
2 parents 12468de + 68a02f6 commit 803aecf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
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

0 comments on commit 803aecf

Please sign in to comment.