From 385865b103447c1e7c5b70839aedbd3d501f8d86 Mon Sep 17 00:00:00 2001 From: Unarray <48868686+Unarray@users.noreply.github.com> Date: Sat, 26 Aug 2023 18:07:29 +0200 Subject: [PATCH] Add `ignore` library --- package.json | 5 ++++- src/utils/filter/filter.ts | 5 +++++ src/utils/filter/index.ts | 1 + tsup.config.ts | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/utils/filter/filter.ts create mode 100644 src/utils/filter/index.ts diff --git a/package.json b/package.json index 3becc9e..287cd17 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,9 @@ ], "author": "Unarray", "license": "MIT", + "dependencies": { + "ignore": "^5.2.4" + }, "devDependencies": { "@bluzzi/eslint-config": "^1.1.0", "@electron/remote": "^2.0.10", @@ -29,7 +32,7 @@ "obsidian": "latest", "tsconfig-paths": "^4.2.0", "tsup": "^7.2.0", - "typescript": "4.7.4" + "typescript": "5.2.2" }, "eslintConfig": { "extends": [ diff --git a/src/utils/filter/filter.ts b/src/utils/filter/filter.ts new file mode 100644 index 0000000..d54c5d0 --- /dev/null +++ b/src/utils/filter/filter.ts @@ -0,0 +1,5 @@ +import ignore from "ignore"; + +export const filter = (items: string[], patterns: string[]): string[] => { + return ignore().add(patterns).filter(items); +}; \ No newline at end of file diff --git a/src/utils/filter/index.ts b/src/utils/filter/index.ts new file mode 100644 index 0000000..e6bf852 --- /dev/null +++ b/src/utils/filter/index.ts @@ -0,0 +1 @@ +export * from "./filter"; \ No newline at end of file diff --git a/tsup.config.ts b/tsup.config.ts index 1e35de6..1479209 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -4,6 +4,9 @@ export default defineConfig((options) => ({ entry: { "main": "src/FileTreeGenerator.ts" }, + noExternal: [ + "ignore" + ], minify: !options.watch, format: "cjs", outDir: "./"