Skip to content

Commit

Permalink
Use path.parse to get file path
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenImp committed Mar 5, 2025
1 parent 2b9bb9a commit bb1f6c3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/list-folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ export const listFolder = async (
for (const dirent of dirs) {
const filePath = path.join(srcPath, dirent.name);
const isDir = dirent.isDirectory();
const ext = path.extname(filePath);
let name = path.basename(filePath).replace(ext, '');
const folder = filePath.replace(name, '').replace(ext, '');
const parsed = path.parse(filePath);
const ext = parsed.ext;
let name = parsed.name;
const folder = parsed.dir;

if (name.endsWith('index')) {
name = srcPath.replace(/\//g, '-') + '-' + name;
Expand Down

0 comments on commit bb1f6c3

Please sign in to comment.