You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need this very much. Too many files and i get "Maximum call stack size exceeded" error. So i have to move some files at a time to a separate directory to work :(
Save it a file like vueclassmigrate.sh and add that to your path.
Usage: navigate to the folder containing the file you wish to migrate. In that directory, call eg. vueclassmigrate.sh MyComponent.vue
# get the value of the first arg passed in
# if no arg is passed, coerce it into "."
if [ -z "$1" ]; then
ARG="."
else
ARG="$1"
fi
# if ARG is ".", then run npx vue-class-migrator migrate -d .
if [ "$ARG" = "." ]; then
npx vue-class-migrator migrate -d .
else
# get the current pwd
ORIGINALPWD=$(pwd)
# if ARG is not ".", then we have been asked to convert a specific file.
# first, we copy this file to a temporary directory
TMPDIR=$(mktemp -d)
cp "$ARG" "$TMPDIR"
# then we cd to the temporary directory
cd "$TMPDIR"
# then we run npx vue-class-migrator migrate -d .
npx vue-class-migrator migrate -d .
# then we print ('cat') the migrated file
# cat "$ARG"
# then we pipe the contents of the migrated file to the original file
cat "$ARG" > "$ORIGINALPWD/$ARG"
# then we delete the temporary directory
rm -rf "$TMPDIR"
fi
It would come in handy to be able to select a single file instead of a whole directory.
The text was updated successfully, but these errors were encountered: