Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
colinhacks committed Jul 17, 2024
1 parent 719efd6 commit cc4c29d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/utils/get-source-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ const extensionMap = {
const distExtensions = Object.keys(extensionMap) as (keyof typeof extensionMap)[];

export const getSourcePath = (
distPath: string,
exportEntry: ExportEntry,
source: string,
dist: string,
checker: (sourcePath: string)=>boolean = fsExists

Check failure on line 38 in src/utils/get-source-path.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Missing trailing comma
): Omit<SourcePath, "exportEntry"> => {

Check failure on line 39 in src/utils/get-source-path.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Strings must use singlequote
const sourcePathUnresolved = source + distPath.slice(dist.length);
const sourcePathUnresolved = source + exportEntry.outputPath.slice(dist.length);

for (const distExtension of distExtensions) {
if (distPath.endsWith(distExtension)) {
if (exportEntry.outputPath.endsWith(distExtension)) {
const sourcePath = tryExtensions(
sourcePathUnresolved.slice(0, -distExtension.length),
extensionMap[distExtension],
Expand All @@ -57,7 +57,7 @@ export const getSourcePath = (
}
}

throw new Error(`Could not find matching source file for export path ${stringify(distPath)}`);
throw new Error(`Could not find matching source file for export path ${stringify(exportEntry.outputPath)}`);
};

interface SourcePath {
Expand All @@ -73,12 +73,11 @@ export const getSourcePaths = (
distPath: string,
cwd: string

Check failure on line 74 in src/utils/get-source-path.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Missing trailing comma
): SourcePath[] =>{
const outputPath = exportEntry.outputPath;
if(exportEntry.outputPath.includes('*')){

// use glob to resolve matches from the packageJsonRoot directory
const matchSet = new Set<string>();
const sourceMatch = getSourcePath(outputPath, sourcePath, distPath, (path)=>{
const sourceMatch = getSourcePath(exportEntry, sourcePath, distPath, (path)=>{
const matches = globSync(path, { cwd });
for(const match of matches) matchSet.add(match);
return matches.length > 0; // always return false to prevent early exit
Expand All @@ -98,6 +97,6 @@ export const getSourcePaths = (

return [{
exportEntry,
...getSourcePath(exportEntry.outputPath, sourcePath, distPath, fsExists)
...getSourcePath(exportEntry, sourcePath, distPath, fsExists)
}]
}

0 comments on commit cc4c29d

Please sign in to comment.