|
7 | 7 |
|
8 | 8 | n exec 18.18.2 npm run webpack
|
9 | 9 |
|
10 |
| -DIR=$1 |
| 10 | +DIR="$1" |
11 | 11 |
|
12 |
| -rm -rf $DIR |
13 |
| -mkdir $DIR |
| 12 | +rm -rf "$DIR" |
| 13 | +mkdir -v "$DIR" |
14 | 14 |
|
15 | 15 | echo "Copying Trilium to build directory $DIR"
|
16 | 16 |
|
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 |
28 | 24 |
|
29 | 25 | # run in subshell (so we return to original dir)
|
30 | 26 | (cd $DIR && n exec 18.18.2 npm install --only=prod)
|
31 | 27 |
|
| 28 | +if [[ -d "$DIR"/node_modules ]]; then |
32 | 29 | # 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 |
39 | 33 |
|
40 | 34 | # 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 |
44 | 39 |
|
45 | 40 | find $DIR/libraries -name "*.map" -type f -delete
|
46 | 41 |
|
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/ |
49 | 46 |
|
50 |
| -rm -rf $DIR/src/public/app |
| 47 | +rm -rf "$d"/app |
| 48 | +unset f d DIR |
0 commit comments