-
Notifications
You must be signed in to change notification settings - Fork 0
/
codemod-test-fixture.sh
executable file
·44 lines (37 loc) · 1022 Bytes
/
codemod-test-fixture.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env sh
#----------
#
# A. Purpose
#
# Fix the expected output of a test fixture after updating the source code.
#
# B. Usage
#
# For named arguments, do not include `=` between the flag and the value.
# Positional arguments are to appear at the end.
#
# ./codemod-test-fixture.sh [OPTIONAL-FLAGS] <FIXTURE-NAME>
#
#---------
# Get named arguments for the binary
while getopts ":N:" flag
do
case $flag in
N) NAMED_ARGUMENTS=$OPTARG;;
esac
done
# Get fixture name
FIXTURE=${@:$OPTIND:1}
if [ ! $FIXTURE ]
then
echo "ERROR: Please specify the fixture name.\n"
exit 1
elif [ ! -d "tests/fixtures/$FIXTURE/input" ]
then
echo "ERROR: Input folder \`tests/fixtures/$FIXTURE/input\` does not exist.\n"
exit 1
fi
rm -r "tests/fixtures/$FIXTURE/output"
cp -r "tests/fixtures/$FIXTURE/input" "tests/fixtures/$FIXTURE/output"
./dist/bin/ember-codemod-remove-inject-as-service.js $NAMED_ARGUMENTS --root="tests/fixtures/$FIXTURE/output"
echo "SUCCESS: Updated the output of $FIXTURE.\n"