1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00
metamask-extension/development/generate-migration.sh
Nicholas Ellul 033b529c17
Fix script to build migrations by having it use the .ts template (#18878)
* Fix script to build migrations

* Validate version is a number
2023-05-10 14:45:19 -04:00

28 lines
588 B
Bash
Executable File

#! /bin/bash
validate-number(){
re='^[0-9]+$'
if [[ ! $1 =~ $re ]]; then
echo "Error: The value must be a number." >&2
exit 1
fi
}
g-migration() {
[[ -z "$1" ]] && { echo "Migration version is required!" ; exit 1; }
local vnum=$1
validate-number "$vnum"
if (($1 < 100)); then
vnum=0$1
fi
touch app/scripts/migrations/"$vnum".ts
cp app/scripts/migrations/template.ts app/scripts/migrations/"$vnum".ts
touch app/scripts/migrations/"$vnum".test.js
cp app/scripts/migrations/template.test.js app/scripts/migrations/"$vnum".test.js
}
g-migration "$1"