aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-08-02 23:26:53 +0800
committerFabio Berger <me@fabioberger.com>2018-08-02 23:26:53 +0800
commit987971bd59c282e885679576262732e9afa297bb (patch)
treeb3f09601b0d778d776778ff93386d7170b373e57
parent71a2f2d72172e4138b3d4d40ab6bbee4b90e4cf7 (diff)
downloaddexon-0x-contracts-987971bd59c282e885679576262732e9afa297bb.tar.gz
dexon-0x-contracts-987971bd59c282e885679576262732e9afa297bb.tar.zst
dexon-0x-contracts-987971bd59c282e885679576262732e9afa297bb.zip
Fix bug where if there were multiple matches, it wouldn't always take the longest match
-rw-r--r--packages/monorepo-scripts/src/utils/publish_utils.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/packages/monorepo-scripts/src/utils/publish_utils.ts b/packages/monorepo-scripts/src/utils/publish_utils.ts
index 3cdd2c4fb..974fb4d0d 100644
--- a/packages/monorepo-scripts/src/utils/publish_utils.ts
+++ b/packages/monorepo-scripts/src/utils/publish_utils.ts
@@ -274,7 +274,7 @@ function findExportPathGivenTypedocName(
packageName: string,
typedocName: string,
): string {
- const typeDocNameWithoutQuotes = _.replace(typedocName, '"', '');
+ const typeDocNameWithoutQuotes = _.replace(typedocName, /"/g, '');
const sanitizedExportPathToExportPath: { [sanitizedName: string]: string } = {};
const exportPaths = _.keys(exportPathToExportedItems);
const sanitizedExportPaths = _.map(exportPaths, exportPath => {
@@ -292,7 +292,13 @@ function findExportPathGivenTypedocName(
sanitizedExportPathToExportPath[exportPath] = exportPath;
return exportPath;
});
- const matchingSanitizedExportPathIfExists = _.find(sanitizedExportPaths, p => {
+ // We need to sort the exportPaths by length (longest first), so that the match finding will pick
+ // longer matches before shorter matches, since it might match both, but the longer match is more
+ // precisely what we are looking for.
+ const sanitizedExportPathsSortedByLength = sanitizedExportPaths.sort((a: string, b: string) => {
+ return b.length - a.length;
+ });
+ const matchingSanitizedExportPathIfExists = _.find(sanitizedExportPathsSortedByLength, p => {
return _.startsWith(typeDocNameWithoutQuotes, p);
});
if (_.isUndefined(matchingSanitizedExportPathIfExists)) {