Skip to content
Snippets Groups Projects
Commit 93597723 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix: better yarn.lock regex

parent de5c4b87
No related merge requests found
...@@ -15,6 +15,15 @@ string-width@^1.0.1: ...@@ -15,6 +15,15 @@ string-width@^1.0.1:
is-fullwidth-code-point "^2.0.0" is-fullwidth-code-point "^2.0.0"
strip-ansi "^4.0.0" strip-ansi "^4.0.0"
"@embroider/addon-shim@^0.48.0":
version "0.48.0"
resolved "https://registry.yarnpkg.com/@embroider/addon-shim/-/addon-shim-0.48.0.tgz#2a950ecb82c45ae53e801bcddfd26dc420cac9e8"
integrity sha512-hu2Yzv5xXHl1vCzkcybjyjCK2/fHwKPDJ5xpwRlvASU/8WMBVLekQQ9Tt8WhPMZJHdMkzIWchAPGkLZaKaeXmA==
dependencies:
"@embroider/shared-internals" "^0.48.0"
ember-auto-import "^2.2.0"
semver "^7.3.5"
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3" version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
......
...@@ -117,5 +117,29 @@ describe('manager/npm/update/locked-dependency/yarn-lock/replace', () => { ...@@ -117,5 +117,29 @@ describe('manager/npm/update/locked-dependency/yarn-lock/replace', () => {
" "
`); `);
}); });
it('handles quoted', () => {
const res = replaceConstraintVersion(
yarnLock2,
'@embroider/addon-shim',
'^0.48.0',
'0.48.1'
);
expect(res).not.toEqual(yarnLock2);
const diffRes = Diff.diffLines(yarnLock2, res);
const addedSections = diffRes.filter((item) => item.added);
const removedSections = diffRes.filter((item) => item.removed);
expect(addedSections).toHaveLength(1);
expect(removedSections).toHaveLength(1);
expect(addedSections[0].value).toMatchInlineSnapshot(`
" version: \\"0.48.1\\"
"
`);
expect(removedSections[0].value).toMatchInlineSnapshot(`
" version \\"0.48.0\\"
resolved \\"https://registry.yarnpkg.com/@embroider/addon-shim/-/addon-shim-0.48.0.tgz#2a950ecb82c45ae53e801bcddfd26dc420cac9e8\\"
integrity sha512-hu2Yzv5xXHl1vCzkcybjyjCK2/fHwKPDJ5xpwRlvASU/8WMBVLekQQ9Tt8WhPMZJHdMkzIWchAPGkLZaKaeXmA==
"
`);
});
}); });
}); });
...@@ -14,7 +14,7 @@ export function replaceConstraintVersion( ...@@ -14,7 +14,7 @@ export function replaceConstraintVersion(
} }
const depNameConstraint = `${depName}@${constraint}`; const depNameConstraint = `${depName}@${constraint}`;
const escaped = depNameConstraint.replace(/(@|\^|\.|\\)/g, '\\$1'); const escaped = depNameConstraint.replace(/(@|\^|\.|\\)/g, '\\$1');
const matchString = `(${escaped}((",|,)[^\n:]+)?:\n)(.*\n)*?(\\s+dependencies|\n[@a-z])`; const matchString = `(${escaped}(("|",|,)[^\n:]*)?:\n)(.*\n)*?(\\s+dependencies|\n[@a-z])`;
// yarn will fill in the details later // yarn will fill in the details later
const matchResult = regEx(matchString).exec(lockFileContent); const matchResult = regEx(matchString).exec(lockFileContent);
// istanbul ignore if // istanbul ignore if
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment