Skip to content

Commit

Permalink
fix(version): make sure we always have regex match array (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Jul 24, 2022
1 parent ac52574 commit ba34849
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/core/src/package.ts
Expand Up @@ -305,9 +305,8 @@ export class Package {
// when using explicit `workspace:` protocol
if (resolved.explicitWorkspace) {
const workspaceTarget = resolved?.workspaceTarget ?? '';
const [_, _wsTxt, operatorPrefix, rangePrefix] = workspaceTarget.match(
/^(workspace:)?([<>=]{0,2})?([*^~])?(.*)$/
) as RegExpMatchArray;
const [_, _wsTxt, operatorPrefix, rangePrefix] =
workspaceTarget.match(/^(workspace:)?([<>=]{0,2})?([*^~])?(.*)$/) || [];

if (operatorPrefix) {
// with workspace it might include an operator, if so use it like "workspace:>=1.2.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/version/src/lib/update-lockfile-version.ts
Expand Up @@ -100,7 +100,7 @@ export function updateNpmLockFileVersion2(obj: any, pkgName: string, newVersion:
} else {
if (k === pkgName) {
// e.g.: "@lerna-lite/core": "^0.1.2",
const [_, versionPrefix, _versionStr] = obj[k].match(/^([\^~])?(.*)$/);
const [_, versionPrefix, _versionStr] = obj[k].match(/^([\^~])?(.*)$/) || [];
obj[k] = `${versionPrefix}${newVersion}`;
} else if (k === 'name' && obj[k] === pkgName && obj['version'] !== undefined) {
// e.g. "packages/version": { "name": "@lerna-lite/version", "version": "0.1.2" }
Expand Down

0 comments on commit ba34849

Please sign in to comment.