Skip to content

Commit

Permalink
fix(semver): fix handling of non-object arrays in options
Browse files Browse the repository at this point in the history
fixes a problem with the introduced recursive replacement of template-strings, where arrays of primitive datatypes were handled like an object.
  • Loading branch information
ndrsg committed Jun 6, 2022
1 parent 0e7e409 commit dbd7758
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ describe(runPostTargets.name, () => {
},
],
},
arrayWithStrings: [
"first-${version}",
"seconnd-${version}"
]
});

const templateStringContext = {
Expand Down Expand Up @@ -289,6 +293,10 @@ describe(runPostTargets.name, () => {
},
],
},
arrayWithStrings: [
"first-2.0.0",
"seconnd-2.0.0"
]
});
done();
},
Expand Down
9 changes: 8 additions & 1 deletion packages/semver/src/executors/version/utils/post-target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ export function _getTargetOptions({
(optionsAccumulator, [option, value]) => {
const resolvedValue = Array.isArray(value)
? value.map((_element) =>
_getTargetOptions({ options: _element, context })
typeof _element !== "object"
? coerce(
createTemplateString(
(_element as number | string | boolean).toString(),
context
)
)
: _getTargetOptions({ options: _element, context })
)
: typeof value === 'object'
? _getTargetOptions({
Expand Down

0 comments on commit dbd7758

Please sign in to comment.