Skip to content

Instantly share code, notes, and snippets.

@c9n
Created August 9, 2021 03:15
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 c9n/0a6f29485cd9de0828d274ce3d24974d to your computer and use it in GitHub Desktop.
Save c9n/0a6f29485cd9de0828d274ce3d24974d to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Created by LYNN
# At 2018-07-06 09:24:56
#
# Usage:
# px2rpx.sh { path }
#
# Example:
# cd { project root path }
# tools/px2rpx.sh by_mini/pages/address
echo "[ working directory ] => `pwd`"
if [ $# -eq 0 ]; then
echo "NO TARGET"
exit
else
target=$1
fi
if [ ! -d "$target" ]; then
echo "[E] 目标文件夹不存在 => $target";
exit
fi
find $target -name "*.wxss" -print0 | while read -d $'\0' file
do
echo "[ processing ] => $file"
perl -i -pe 's/(\d+)(px)/($1*2).(rpx)/ge' $file
done
echo "[ Done √ ]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment