Skip to content

Build your personal knowledge base with Trilium Notes

build(copy-trilium): do all the work inside build dir, no target directory needed anymore

Panagiotis Papadopoulos1ae5c430106a
diff --git a/bin/build-server.sh b/bin/build-server.sh
index ff2912470d..17a50929bd 100755
--- a/bin/build-server.sh
+++ b/bin/build-server.sh
@@ -43,7 +43,7 @@ echo "Package directory: $PKG_DIR"
if [ "$1" != "DONTCOPY" ]
then
# Need to modify copy-trilium.sh to accept the target directory
- ./bin/copy-trilium.sh "$PKG_DIR"
+ ./bin/copy-trilium.sh
fi
cd dist
diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh
index bd3bd4a5a8..e7e688bffc 100755
--- a/bin/copy-trilium.sh
+++ b/bin/copy-trilium.sh
@@ -3,10 +3,8 @@
set -e # Fail on any command error
shopt -s globstar
-if [[ $# -eq 0 ]] ; then
- echo "Missing argument of target directory"
- exit 1
-fi
+BUILD_DIR="./build"
+
if ! [[ $(which npm) ]]; then
echo "Missing npm"
exit 1
@@ -18,29 +16,29 @@ npm run build:prepare-dist
echo Build finished
# Patch package.json main
-sed -i 's/.\/dist\/electron-main.js/electron-main.js/g' "$DIR/package.json"
+sed -i 's/.\/dist\/electron-main.js/electron-main.js/g' "$BUILD_DIR/package.json"
# run in subshell (so we return to original dir)
-(cd $DIR && npm ci --omit=dev)
+(cd $BUILD_DIR && npm ci --omit=dev)
-if [[ -d "$DIR"/node_modules ]]; then
+if [[ -d "$BUILD_DIR"/node_modules ]]; then
# cleanup of useless files in dependencies
for d in 'image-q/demo' \
'@excalidraw/excalidraw/dist/excalidraw-assets-dev' '@excalidraw/excalidraw/dist/excalidraw.development.js' '@excalidraw/excalidraw/dist/excalidraw-with-preact.development.js' \
'mermaid/dist/mermaid.js' \
'boxicons/svg' 'boxicons/node_modules/react'/* \
'@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do
- [[ -e "$DIR"/node_modules/"$d" ]] && rm -r "$DIR"/node_modules/"$d"
+ [[ -e "$BUILD_DIR"/node_modules/"$d" ]] && rm -r "$BUILD_DIR"/node_modules/"$d"
done
# delete all tests (there are often large images as test file for jimp etc.)
for d in 'test' 'docs' 'demo' 'example'; do
- find "$DIR"/node_modules -name "$d" -exec rm -rf {} +
+ find "$BUILD_DIR"/node_modules -name "$d" -exec rm -rf {} +
done
fi
-find $DIR/libraries -name "*.map" -type f -delete
-find $DIR/node_modules -name "*.map" -type f -delete
-find $DIR -name "*.ts" -type f -delete
+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 DIR
+unset f d BUILD_DIR