-
-
Notifications
You must be signed in to change notification settings - Fork 282
/
append-patches.sh
executable file
Β·84 lines (59 loc) Β· 2.17 KB
/
append-patches.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# make sure errors stop the script
set -e
npm install
echo "add patch-package"
npm add $1
function patch-package {
./node_modules/.bin/patch-package "$@"
}
function replace {
npx replace "$1" "$2" node_modules/left-pad/index.js
}
echo "making an initial patch file does not add a sequence number to the file by default"
replace 'use strict' 'use patch-package'
patch-package left-pad
echo "SNAPSHOT: basic patch file"
ls patches
echo "END SNAPSHOT"
echo "using --apend creates a patch file with a sequence number and updates the original patch file"
replace 'use patch-package' 'use a million dollars'
patch-package left-pad --append 'MillionDollars'
echo "SNAPSHOT: after appending a patch file"
ls patches
echo "END SNAPSHOT"
echo "SNAPSHOT: the second patch file should go from patch-package to a million dollars"
cat patches/left-pad*MillionDollars.patch
echo "END SNAPSHOT"
echo "we can squash the patches together by deleting the patch files"
rm patches/left-pad*patch
patch-package left-pad --append 'FirstPatch'
echo "SNAPSHOT: creating a first patch file with --append"
ls patches
echo "END SNAPSHOT"
echo "SNAPSHOT: the squashed patch file should go from use strict to a million dollars"
cat patches/left-pad*FirstPatch.patch
echo "END SNAPSHOT"
echo "i can update an appended patch file"
replace 'use a million dollars' 'use a billion dollars'
patch-package left-pad --append 'BillionDollars'
echo "SNAPSHOT: after appending a billion dollars"
ls patches
echo "END SNAPSHOT"
replace 'use a billion dollars' 'use a trillion dollars'
patch-package left-pad
echo "SNAPSHOT: after updating the appended patch file to a TRILLION dollars"
cat patches/left-pad*BillionDollars.patch
echo "END SNAPSHOT"
echo "if one of the patches in the sequence is invalid, the sequence is not applied"
npx replace 'use strict' 'use bananas' patches/*FirstPatch.patch
echo "SNAPSHOT: patch-package fails when a patch in the sequence is invalid"
if patch-package left-pad --append 'Bananas' ; then
exit 1
fi
echo "END SNAPSHOT"
echo "SNAPSHOT: --append is not compatible with --create-issue"
if patch-package left-pad --append 'Bananas' --create-issue ; then
exit 1
fi
echo "END SNAPSHOT"