Skip to content

Commit

Permalink
Merge pull request microsoft#4074 from chengcyber/fix-look-by-path
Browse files Browse the repository at this point in the history
Fix look by path
  • Loading branch information
iclanton authored Apr 25, 2023
2 parents 5241a84 + bd90f83 commit 54cb235
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Fix an issue where the last character in a project's path is ignored when determining which files contribute to the project's cache ID.",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
2 changes: 1 addition & 1 deletion libraries/rush-lib/src/logic/LookupByPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class LookupByPath<TItem> {
}

// Last segment
if (previousIndex + 1 < input.length) {
if (previousIndex < input.length) {
yield {
prefix: input.slice(previousIndex, input.length),
index: input.length
Expand Down
4 changes: 4 additions & 0 deletions libraries/rush-lib/src/logic/test/LookupByPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ describe(LookupByPath.iteratePathSegments.name, () => {
const result = [...LookupByPath.iteratePathSegments('foo/bar/baz')];
expect(result).toEqual(['foo', 'bar', 'baz']);
});
it('returns correct last single character segment', () => {
const result = [...LookupByPath.iteratePathSegments('foo/a')];
expect(result).toEqual(['foo', 'a']);
});
});

describe(LookupByPath.prototype.findChildPath.name, () => {
Expand Down

0 comments on commit 54cb235

Please sign in to comment.