Sfoglia il codice sorgente

Fix build script on macOS (#406)

Some commands like `sed` or `install` behave differently on Linux and macOS. This commit implements some changes to the build script so that the resulting output is the same on both Linux and macOS.

Signed-off-by: Joel Fischer <jfjoel.fischer@gmail.com>
Joel 7 anni fa
parent
commit
bf16b248f6
2 ha cambiato i file con 13 aggiunte e 3 eliminazioni
  1. 1 0
      .gitignore
  2. 12 3
      dist/package.sh

+ 1 - 0
.gitignore

@@ -21,3 +21,4 @@ node_modules/
 
 #debug stuff
 npm-debug.log
+.DS_Store

+ 12 - 3
dist/package.sh

@@ -28,7 +28,9 @@ if [ -e "release" ]; then
     done
 fi
 
-VERSION=$(grep "\"version\"" package.json  | sed 's/\s*\"version\": \"\([^\"]*\).*/\1/')
+
+VERSION=$(grep "\"version\"" package.json  | sed 's/[[:blank:]]*\"version\": \"\([^\"]*\).*/\1/')
+
 DIR="release/threema-web-$VERSION"
 
 echo "+ Create release directory..."
@@ -78,12 +80,19 @@ targets=(
     sdp/sdp.js
 )
 
+
 for target in "${targets[@]}"; do
-    install -D "node_modules/$target" "$DIR/node_modules/$target"
+
+    if [[ "$OSTYPE" == "darwin"* ]]; then
+        ditto "node_modules/$target" "$DIR/node_modules/$target"
+    else
+        install -D "node_modules/$target" "$DIR/node_modules/$target"
+    fi
 done
 
+
 echo "+ Update version number..."
-sed -i "s/\[\[VERSION\]\]/${VERSION}/g" $DIR/index.html $DIR/troubleshoot/index.html $DIR/dist/app.js $DIR/version.txt
+sed -i '' -e "s/\[\[VERSION\]\]/${VERSION}/g" $DIR/index.html $DIR/troubleshoot/index.html $DIR/dist/app.js $DIR/version.txt
 
 echo "+ Update permissions..."
 find $DIR/ -type f -exec chmod 644 {} \;