mirror of
https://github.com/unarray/file-tree-generator.git
synced 2026-07-22 08:40:29 +00:00
Remove specific comportement from parser
This commit is contained in:
parent
f6fe5c18fd
commit
0807664519
1 changed files with 2 additions and 4 deletions
|
|
@ -1,15 +1,13 @@
|
|||
import path from "path";
|
||||
import type { ExplorerEntity } from "./parser.type";
|
||||
import { escapeString } from "#/utils/regex";
|
||||
import { haveChilds } from "./parser.util";
|
||||
|
||||
export const filesToExplorerEntity = (files: string[], removeBasePath = "", separator: string | null = null): ExplorerEntity => {
|
||||
export const filesToExplorerEntity = (files: string[], separator: string | null = null): ExplorerEntity => {
|
||||
separator = separator ?? path.sep;
|
||||
const regex = new RegExp(`^${escapeString(removeBasePath)}`);
|
||||
const structure: ExplorerEntity = {};
|
||||
|
||||
for (const file of files) {
|
||||
const parts = file.replace(regex, "").split(separator);
|
||||
const parts = file.split(separator);
|
||||
let current = structure;
|
||||
|
||||
for (const part of parts) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue