Skip to content

Commit

Permalink
Merge branch 'master' into paginated-requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 authored Jan 30, 2024
2 parents 715a242 + d5f88d2 commit cbcf8a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/tsc-transform-imports/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@redhat-cloud-services/tsc-transform-imports",
"version": "1.0.6",
"version": "1.0.7",
"main": "index.js",
"types": "index.d.ts",
"dependencies": {
Expand Down
14 changes: 9 additions & 5 deletions packages/tsc-transform-imports/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,35 @@ const VARIANT_MATCH = /Variants?$/g;
const POSITION_MATCH = /Position$/g;
const SIZE_MATCH = /Sizes?$/g;

function filterNonStableLocation(location: string) {
return !location.includes('next') && !location.includes('deprecated');
}

function getPossibleLocations(roots: string[], nameBinding: string) {
let moduleLocation = roots
.map((root) => glob.sync(`${root}/dist/esm/**/${nameBinding}.js`).filter((p) => !p.includes('deprecated')))
.map((root) => glob.sync(`${root}/dist/esm/**/${nameBinding}.js`).filter(filterNonStableLocation))
.find((r) => r.length > 0)?.[0];
if (!moduleLocation && nameBinding.match(PROPS_MATCH)) {
moduleLocation = roots
.map((root) => glob.sync(`${root}/dist/esm/**/${nameBinding.replace(PROPS_MATCH, '')}.js`).filter((p) => !p.includes('deprecated')))
.map((root) => glob.sync(`${root}/dist/esm/**/${nameBinding.replace(PROPS_MATCH, '')}.js`).filter(filterNonStableLocation))
.find((r) => r.length > 0)?.[0];
}

if (!moduleLocation && nameBinding.match(VARIANT_MATCH)) {
moduleLocation = roots
.map((root) => glob.sync(`${root}/dist/esm/**/${nameBinding.replace(VARIANT_MATCH, '')}.js`).filter((p) => !p.includes('deprecated')))
.map((root) => glob.sync(`${root}/dist/esm/**/${nameBinding.replace(VARIANT_MATCH, '')}.js`).filter(filterNonStableLocation))
.find((r) => r.length > 0)?.[0];
}

if (!moduleLocation && nameBinding.match(POSITION_MATCH)) {
moduleLocation = roots
.map((root) => glob.sync(`${root}/dist/esm/**/${nameBinding.replace(POSITION_MATCH, '')}.js`).filter((p) => !p.includes('deprecated')))
.map((root) => glob.sync(`${root}/dist/esm/**/${nameBinding.replace(POSITION_MATCH, '')}.js`).filter(filterNonStableLocation))
.find((r) => r.length > 0)?.[0];
}

if (!moduleLocation && nameBinding.match(SIZE_MATCH)) {
moduleLocation = roots
.map((root) => glob.sync(`${root}/dist/esm/**/${nameBinding.replace(SIZE_MATCH, '')}.js`).filter((p) => !p.includes('deprecated')))
.map((root) => glob.sync(`${root}/dist/esm/**/${nameBinding.replace(SIZE_MATCH, '')}.js`).filter(filterNonStableLocation))
.find((r) => r.length > 0)?.[0];
}

Expand Down

0 comments on commit cbcf8a7

Please sign in to comment.