Skip to content

Commit ff5d5d2

Browse files
Reduce warnings count caused by bin/copy-trilium.sh
1 parent 1f95e88 commit ff5d5d2

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

bin/copy-trilium.sh

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,42 @@ fi
77

88
n exec 18.18.2 npm run webpack
99

10-
DIR=$1
10+
DIR="$1"
1111

12-
rm -rf $DIR
13-
mkdir $DIR
12+
rm -rf "$DIR"
13+
mkdir -v "$DIR"
1414

1515
echo "Copying Trilium to build directory $DIR"
1616

17-
cp -r images $DIR/
18-
cp -r libraries $DIR/
19-
cp -r src $DIR/
20-
cp -r db $DIR/
21-
cp -r package.json $DIR/
22-
cp -r package-lock.json $DIR/
23-
cp -r README.md $DIR/
24-
cp -r LICENSE $DIR/
25-
cp -r config-sample.ini $DIR/
26-
cp -r electron.js $DIR/
27-
cp webpack-* $DIR/
17+
for d in 'images' 'libraries' 'src' 'db'; do
18+
cp -r "$d" "$DIR"/
19+
done
20+
for f in 'package.json' 'package-lock.json' 'README.md' 'LICENSE' 'config-sample.ini' 'electron.js'; do
21+
cp "$f" "$DIR"/
22+
done
23+
cp webpack-* "$DIR"/ # here warning because there is no 'webpack-*', but webpack.config.js only
2824

2925
# run in subshell (so we return to original dir)
3026
(cd $DIR && n exec 18.18.2 npm install --only=prod)
3127

28+
if [[ -d "$DIR"/node_modules ]]; then
3229
# cleanup of useless files in dependencies
33-
rm -r $DIR/node_modules/image-q/demo
34-
rm -r $DIR/node_modules/better-sqlite3/Release
35-
rm -r $DIR/node_modules/better-sqlite3/deps/sqlite3.tar.gz
36-
rm -r $DIR/node_modules/@jimp/plugin-print/fonts
37-
rm -r $DIR/node_modules/jimp/browser
38-
rm -r $DIR/node_modules/jimp/fonts
30+
for d in 'image-q/demo' 'better-sqlite3/Release' 'better-sqlite3/deps/sqlite3.tar.gz' '@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do
31+
[[ -e "$DIR"/node_modules/"$d" ]] && rm -rv "$DIR"/node_modules/"$d"
32+
done
3933

4034
# delete all tests (there are often large images as test file for jimp etc.)
41-
find $DIR/node_modules -name test -exec rm -rf {} \;
42-
find $DIR/node_modules -name docs -exec rm -rf {} \;
43-
find $DIR/node_modules -name demo -exec rm -rf {} \;
35+
for d in 'test' 'docs' 'demo'; do
36+
find "$DIR"/node_modules -name "$d" -exec rm -rf {} \;
37+
done
38+
fi
4439

4540
find $DIR/libraries -name "*.map" -type f -delete
4641

47-
cp $DIR/src/public/app/share.js $DIR/src/public/app-dist/
48-
cp -r $DIR/src/public/app/doc_notes $DIR/src/public/app-dist/
42+
d="$DIR"/src/public
43+
[[ -d "$d"/app-dist ]] || mkdir -pv "$d"/app-dist
44+
cp -v "$d"/app/share.js "$d"/app-dist/
45+
cp -rv "$d"/app/doc_notes "$d"/app-dist/
4946

50-
rm -rf $DIR/src/public/app
47+
rm -rf "$d"/app
48+
unset f d DIR

0 commit comments

Comments
 (0)