From 6749d8084bb6f8b56aa330ef6d7d0d0790f3a29c Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 02:15:17 +0100 Subject: [PATCH] build(copy-dist): add further cleanupNodeModules functionality deleting of ts and map files from node_modules folder, adapted from copy-trilium.sh. --- bin/copy-dist.ts | 13 +++++++++++++ bin/copy-trilium.sh | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 38413b1b9..9fb520907 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -87,5 +87,18 @@ function cleanupNodeModules() { .map(el => path.join(DEST_DIR, el.parentPath, el.name)) .forEach(dir => fs.removeSync(dir)); + + // Delete unnecessary files based on file extension + const filterableFileExt = new Set([ + "ts", + "map" + ]) + + nodeDir + // TriliumNextTODO: check if we can improve this naive file ext matching + .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || "")) + .map(file => path.join(DEST_DIR, file.parentPath, file.name)) + .forEach(file => fs.removeSync(file)); + } diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index e99bf08b9..6aea1175c 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -22,7 +22,5 @@ if [[ -d "$BUILD_DIR"/node_modules ]]; then fi find $BUILD_DIR/libraries -name "*.map" -type f -delete -find $BUILD_DIR/node_modules -name "*.map" -type f -delete -find $BUILD_DIR -name "*.ts" -type f -delete unset f d BUILD_DIR