-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Alex Dupre <ale@FreeBSD.org>
- Loading branch information
Showing
3 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'typechain': patch | ||
--- | ||
|
||
Fix the detection of inputs root in some specific scenarios |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
export function lowestCommonPath(paths: string[]) { | ||
const pathParts = paths.map((path) => path.split(/[\\/]/)) | ||
const commonParts = pathParts[0].filter((part, index) => pathParts.every((parts) => parts[index] === part)) | ||
const commonParts = [] as string[] | ||
const maxParts = Math.min.apply( | ||
null, | ||
pathParts.map((p) => p.length), | ||
) | ||
for (let i = 0; i < maxParts; i++) { | ||
const part = pathParts[0][i] | ||
if (pathParts.slice(1).every((otherPath) => otherPath[i] === part)) { | ||
commonParts.push(part) | ||
} else { | ||
break | ||
} | ||
} | ||
return commonParts.join('/') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters