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
1 changed files with 6 additions and 15 deletions

View File

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