@@ -4,47 +4,49 @@ if [[ $# -eq 0 ]] ; then
4
4
echo " Missing argument of target directory"
5
5
exit 1
6
6
fi
7
+ if ! [[ $( which npm) ]]; then
8
+ echo " Missing npm"
9
+ exit 1
10
+ fi
7
11
8
- n exec 18.18.2 npm run webpack
12
+ n exec 18.18.2 npm run webpack || npm run webpack
9
13
10
- DIR=$1
14
+ DIR=" $1 "
11
15
12
- rm -rf $DIR
13
- mkdir $DIR
16
+ rm -rf " $DIR "
17
+ mkdir -pv " $DIR "
14
18
15
19
echo " Copying Trilium to build directory $DIR "
16
20
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 /
21
+ for d in ' images' ' libraries' ' src' ' db' ; do
22
+ cp -r " $d " " $DIR " /
23
+ done
24
+ for f in ' package.json' ' package-lock.json' ' README.md' ' LICENSE' ' config-sample.ini' ' electron.js' ; do
25
+ cp " $f " " $DIR " /
26
+ done
27
+ cp webpack-* " $DIR " / # here warning because there is no 'webpack-*', but webpack.config.js only
28
28
29
29
# run in subshell (so we return to original dir)
30
30
(cd $DIR && n exec 18.18.2 npm install --only=prod)
31
31
32
+ if [[ -d " $DIR " /node_modules ]]; then
32
33
# 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
34
+ for d in ' image-q/demo' ' better-sqlite3/Release' ' better-sqlite3/deps/sqlite3.tar.gz' ' @jimp/plugin-print/fonts' ' jimp/browser' ' jimp/fonts' ; do
35
+ [[ -e " $DIR " /node_modules/" $d " ]] && rm -rv " $DIR " /node_modules/" $d "
36
+ done
39
37
40
38
# 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 {} \;
39
+ for d in ' test' ' docs' ' demo' ; do
40
+ find " $DIR " /node_modules -name " $d " -exec rm -rf {} \;
41
+ done
42
+ fi
44
43
45
44
find $DIR /libraries -name " *.map" -type f -delete
46
45
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/
46
+ d=" $DIR " /src/public
47
+ [[ -d " $d " /app-dist ]] || mkdir -pv " $d " /app-dist
48
+ cp " $d " /app/share.js " $d " /app-dist/
49
+ cp -r " $d " /app/doc_notes " $d " /app-dist/
49
50
50
- rm -rf $DIR /src/public/app
51
+ rm -rf " $d " /app
52
+ unset f d DIR
0 commit comments