Replace sed with jq in build-desktop.sh

This commit is contained in:
Pedro Pombeiro 2019-02-19 19:20:47 +01:00
parent f7779023ca
commit 1c7eaf1b76
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647

View File

@ -165,21 +165,12 @@ function buildClojureScript() {
echo "" echo ""
# Add path to javascript bundle to package.json # Add path to javascript bundle to package.json
jsBundleLine="\"desktopJSBundlePath\": \"$WORKFOLDER/Status.jsbundle\"" local jsBundleLine="\"desktopJSBundlePath\": \"$WORKFOLDER/Status.jsbundle\""
jsPackagePath=$(joinExistingPath "$STATUSREACTPATH" 'desktop_files/package.json.orig') local jsPackagePath=$(joinExistingPath "$STATUSREACTPATH" 'desktop_files/package.json.orig')
if grep -Fq "$jsBundleLine" "$jsPackagePath"; then local tmp=$(mktemp)
echo -e "${GREEN}Found line in package.json.${NC}" jq ".=(. + {$jsBundleLine})" "$jsPackagePath" > "$tmp" && mv "$tmp" "$jsPackagePath"
else
# Add line to package.json just before "dependencies" line
if is_macos; then
sed -i '' -e "/\"dependencies\":/i\\
\ $jsBundleLine," "$jsPackagePath"
else
sed -i -- "/\"dependencies\":/i\ $jsBundleLine," "$jsPackagePath"
fi
echo -e "${YELLOW}Added 'desktopJSBundlePath' line to $jsPackagePath:${NC}" echo -e "${YELLOW}Added 'desktopJSBundlePath' line to $jsPackagePath:${NC}"
echo "" echo ""
fi
} }
function compile() { function compile() {