forked from marksandspencer/nx-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
local-test.sh
executable file
·65 lines (54 loc) · 1.53 KB
/
local-test.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
PLUGIN_NAME="nx-playwright"
PARAMETER_VALIDATION_PROMPT="
Please supply the following arguments:
-w <path to workspace>: absolute path to the workspace with which to test the plugin
-a <app name>: the name of the app with which to test the plugin
-C: if present, stash workspace changes before the test run and clean up afterwards (optional)
For example:
./local-test.sh -w path/to/workspace -a example-app -C"
while getopts w:a:C flag
do
case "${flag}" in
w) workspace=${OPTARG};;
a) app=${OPTARG};;
C) should_stash_and_clean=1;;
esac
done
if [ -z $workspace ] || [ -z $app ]; then
echo "$PARAMETER_VALIDATION_PROMPT"
exit 1
fi
function stash_workspace_changes_if_requested {
if [ $should_stash_and_clean ]; then
echo "Stashing all changes before test"
git stash -u
yarn install --frozen-lockfile
else
echo "Stash not requested"
fi
}
function restore_workspace_if_requested {
if [ $should_stash_and_clean ]; then
git checkout .
git clean -fd
git stash pop
yarn install --frozen-lockfile
else
echo "Restore not required"
fi
}
PLUGIN_NPM_NAME="@mands/$PLUGIN_NAME"
rm -fr dist
yarn nx build $PLUGIN_NAME
pushd dist/packages/$PLUGIN_NAME
yarn link
popd
pushd $workspace
stash_workspace_changes_if_requested
yarn unlink $PLUGIN_NPM_NAME
yarn link $PLUGIN_NPM_NAME
yarn nx generate $PLUGIN_NPM_NAME:project $app-e2e --project $app
yarn nx e2e $app-e2e --skip-nx-cache
restore_workspace_if_requested
popd