Skip to content

Instantly share code, notes, and snippets.

@superRaytin
Created December 6, 2019 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superRaytin/711c453ce98f6cda8a5b5b8dd27f7f62 to your computer and use it in GitHub Desktop.
Save superRaytin/711c453ce98f6cda8a5b5b8dd27f7f62 to your computer and use it in GitHub Desktop.
replace specified content with some else string
#!/bin/sh
# replace name of html entry with fixed "index.html" in cmd file
targetCmdPath="${PWD}/{{ slug }}.sketchplugin/Contents/Sketch/my-command.js"
sed -i -r -E "s/(_webpack_resources\/).+(\.html)/\1index\2/" "$targetCmdPath"
# copy index.html to _webpack_resources
htmlPath="${PWD}/src/dist/index.html"
webpackResourcePath="${PWD}/{{ slug }}.sketchplugin/Contents/Resources/_webpack_resources"
/bin/cp -f "$htmlPath" "$webpackResourcePath"
# remove the backup file which is auto created by sed
targetBackupCmdPath="${PWD}/{{ slug }}.sketchplugin/Contents/Sketch/my-command.js-r"
rm "$targetBackupCmdPath"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment