Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit

Permalink
Remove stripComponents
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jan 24, 2024
1 parent 5897417 commit 3d4e6c7
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/swc/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,10 @@ export function assertCompilationResult<T>(
}
}

/**
* Removes the leading directory, including all parent relative paths
*/
function stripComponents(filename: string) {
const components = filename.split("/").slice(1);
if (!components.length) {
return filename;
}
while (components[0] === "..") {
components.shift();
}
return components.join("/");
}

const cwd = process.cwd();

export function getDest(filename: string, outDir: string, ext?: string) {
const relativePath = slash(relative(cwd, filename));
let base = stripComponents(relativePath);
let base = slash(relative(cwd, filename));
if (ext) {
base = base.replace(/\.\w*$/, ext);
}
Expand Down

0 comments on commit 3d4e6c7

Please sign in to comment.