Skip to content

Commit 881f20c

Browse files
committed
use patch-package bin directly in tests
1 parent eebbf31 commit 881f20c

File tree

27 files changed

+73
-54
lines changed

27 files changed

+73
-54
lines changed

integration-tests/adding-and-deleting-files/adding-and-deleting-files.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
echo "add a file"
89
echo "this is a new file" > node_modules/lodash/newFile.md
@@ -11,14 +12,14 @@ echo "remove a file"
1112
rm node_modules/lodash/fp/__.js
1213

1314
echo "generate patch file"
14-
npx patch-package lodash
15+
patch-package lodash
1516

1617
echo "remove node_modules"
1718
rm -rf node_modules
1819

1920
echo "resintall and patch node_modules"
2021
yarn
21-
npx patch-package
22+
patch-package
2223

2324
echo "check that the file was added"
2425
ls node_modules/lodash/newFile.md

integration-tests/broken-patch-file/broken-patch-file.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
(>&2 echo "SNAPSHOT: patch-package fails when patch file is invalid")
8-
if npx patch-package
9+
if patch-package
910
then
1011
exit 1
1112
fi

integration-tests/custom-patch-dir/custom-patch-dir.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
echo "modify left-pad"
89
npx replace pad patch-package node_modules/left-pad/index.js
910

1011
mkdir my
1112

1213
echo "make patch file"
13-
npx patch-package left-pad --patch-dir my/patches
14+
patch-package left-pad --patch-dir my/patches
1415

1516
ls my/patches/left-pad*
1617

@@ -19,6 +20,6 @@ rimraf node_modules
1920
yarn
2021

2122
echo "run patch-package"
22-
npx patch-package --patch-dir my/patches
23+
patch-package --patch-dir my/patches
2324

2425
grep patch-package node_modules/left-pad/index.js

integration-tests/custom-resolutions/custom-resolutions.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
echo "make changes to dependency/index.js"
89
echo '// hello i am patch-package' > node_modules/dependency/index.js
910

1011
echo "doesn't fail when making a patch"
11-
npx patch-package dependency
12+
patch-package dependency

integration-tests/delete-old-patch-files/delete-old-patch-files.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
echo "apply patch-package"
8-
npx patch-package
9+
patch-package
910

1011
echo "make sure the changes were applied"
1112
grep patch-package node_modules/@types/lodash/index.d.ts
@@ -16,7 +17,7 @@ ls patches/lodash:4.17.11.patch
1617
ls patches/@types/lodash:4.14.120.patch
1718

1819
echo "make patch files again"
19-
npx patch-package lodash @types/lodash
20+
patch-package lodash @types/lodash
2021

2122
echo "make sure the changes were still applied"
2223
grep patch-package node_modules/@types/lodash/index.d.ts

integration-tests/delete-scripts/delete-scripts.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ set -e
22

33
echo 'install without error because package.json is sanitized'
44
yarn add $1
5+
alias patch-package=./node_modules/.bin/patch-package
56

67
echo 'unsnitize package.json'
78
npx replace '<<PREINSTALL>>' preinstall package.json
@@ -14,7 +15,7 @@ fi
1415
npx replace leftPad patchPackage node_modules/left-pad/index.js
1516

1617
echo 'but patch-package still works because it ignores scripts'
17-
npx patch-package left-pad
18+
patch-package left-pad
1819

1920
echo "SNAPSHOT: a patch file got produced"
2021
cat patches/left-pad*.patch

integration-tests/fails-when-no-package/__snapshots__/fails-when-no-package.test.ts.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
exports[`Test fails-when-no-package: no package present failure 1`] = `
44
"SNAPSHOT: no package present failure
55
Error: Patch file found for package left-pad which is not present at node_modules/left-pad
6-
error Command failed with exit code 1.
76
END SNAPSHOT"
87
`;

integration-tests/fails-when-no-package/fails-when-no-package.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
(>&2 echo "SNAPSHOT: no package present failure")
8-
if yarn patch-package; then
9+
if patch-package; then
910
exit 1
1011
fi
1112
(>&2 echo "END SNAPSHOT")

integration-tests/file-mode-changes/file-mode-changes.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
echo "check file permissions 1"
89
./assert-executable.js node_modules/prettier/bin-prettier.js
@@ -17,7 +18,7 @@ echo "check file permissions 2"
1718
./assert-not-executable.js node_modules/prettier/bin-prettier.js
1819

1920
echo "patch prettier"
20-
npx patch-package prettier
21+
patch-package prettier
2122

2223
echo "SNAPSHOT: the patch file"
2324
cat patches/prettier*
@@ -32,7 +33,7 @@ echo "check file permissions 3"
3233
./assert-not-executable.js node_modules/prettier/index.js
3334

3435
echo "run patch-package"
35-
npx patch-package
36+
patch-package
3637

3738
echo "check file permissions 4"
3839
./assert-executable.js node_modules/prettier/index.js

integration-tests/happy-path-npm/happy-path-npm.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ npm i
55

66
echo "add patch-package"
77
npm i $1
8+
alias patch-package=./node_modules/.bin/patch-package
89

910
echo "Add left-pad"
1011
@@ -13,7 +14,7 @@ echo "replace pad with yarn in left-pad/index.js"
1314
npx replace pad npm node_modules/left-pad/index.js
1415

1516
echo "SNAPSHOT: making patch"
16-
npx patch-package left-pad
17+
patch-package left-pad
1718
echo "END SNAPSHOT"
1819

1920
echo "SNAPSHOT: the patch looks like this"

integration-tests/happy-path-yarn/happy-path-yarn.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
echo "Add left-pad"
89
@@ -11,7 +12,7 @@ echo "replace pad with yarn in left-pad/index.js"
1112
npx replace pad yarn node_modules/left-pad/index.js
1213

1314
echo "SNAPSHOT: making patch"
14-
npx patch-package left-pad
15+
patch-package left-pad
1516
echo "END SNAPSHOT"
1617

1718
echo "SNAPSHOT: the patch looks like this"

integration-tests/ignore-whitespace/ignore-whitespace.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
echo "add random bits of whitespace"
89
node add-whitespace.js
910

1011
echo "try to make patch file (should be empty)"
1112
(>&2 echo "SNAPSHOT: empty changeset when adding whitespace")
12-
if npx patch-package alphabet
13+
if patch-package alphabet
1314
then
1415
exit 1
1516
fi
@@ -21,7 +22,7 @@ npx replace 'a' 'patch-package' node_modules/alphabet/index.js
2122
node add-whitespace.js 2
2223

2324
echo "make patch file for line a"
24-
npx patch-package alphabet
25+
patch-package alphabet
2526

2627
echo "SNAPSHOT: line a changed"
2728
cat patches/alphabet*.patch
@@ -30,19 +31,19 @@ echo "END SNAPSHOT"
3031
echo "make sure the patch can be applied to clean files"
3132
rm -rf node_modules
3233
yarn
33-
npx patch-package
34+
patch-package
3435
grep patch-package node_modules/alphabet/index.js
3536

3637
echo "make sure the patch can be applied to dirty files"
3738
rm -rf node_modules
3839
yarn
3940
node add-whitespace.js
40-
npx patch-package
41+
patch-package
4142
grep patch-package node_modules/alphabet/index.js
4243

4344
echo "make sure the patch can be applied to dirty files with different whitespace"
4445
rm -rf node_modules
4546
yarn
4647
node add-whitespace.js 1
47-
npx patch-package
48+
patch-package
4849
grep patch-package node_modules/alphabet/index.js

integration-tests/ignores-scripts-when-making-patch/ignores-scripts-when-making-patch.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
npx replace postinstall lol node_modules/naughty-package/postinstall.sh
89

910
echo "SNAPSHOT: the patch creation output should look normal"
1011
(>&2 echo "SNAPSHOT: there should be no stderr")
11-
npx patch-package naughty-package
12+
patch-package naughty-package
1213
echo "END SNAPSHOT"
1314
(>&2 echo "END SNAPSHOT")
1415

integration-tests/include-exclude-paths/include-exclude-paths.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
echo "edit some files"
89
npx replace exports patchPackage node_modules/lodash/_baseClamp.js
@@ -16,44 +17,44 @@ echo "remove a file"
1617
rm node_modules/lodash/fp/__.js
1718

1819
echo "run patch-package with only __.js included"
19-
npx patch-package lodash --include __
20+
patch-package lodash --include __
2021

2122
echo "SNAPSHOT: only __.js being deleted"
2223
cat patches/lodash*
2324
echo "END SNAPSHOT"
2425

2526
echo "run patch-package excluding the base files"
26-
npx patch-package lodash --exclude base
27+
patch-package lodash --exclude base
2728

2829
echo "SNAPSHOT: no base files"
2930
cat patches/lodash*
3031
echo "END SNAPSHOT"
3132

3233
echo "run patch-package including base and excluding clone"
33-
npx patch-package lodash --include base --exclude clone
34+
patch-package lodash --include base --exclude clone
3435

3536
echo "SNAPSHOT: only base files, no clone files"
3637
cat patches/lodash*
3738
echo "END SNAPSHOT"
3839

3940
echo "run patch package excluding all but flip"
40-
npx patch-package lodash --exclude '^(?!.*flip)'
41+
patch-package lodash --exclude '^(?!.*flip)'
4142

4243
echo "SNAPSHOT: exclude all but flip"
4344
cat patches/lodash*
4445
echo "END SNAPSHOT"
4546

4647
echo "run patch package including newfile (case insensitive)"
47-
npx patch-package lodash --include newfile
48+
patch-package lodash --include newfile
4849

4950
echo "run patch package including newfile (case sensitive)"
50-
if npx patch-package lodash --include newfile --case-sensitive-path-filtering
51+
if patch-package lodash --include newfile --case-sensitive-path-filtering
5152
then
5253
exit 1
5354
fi
5455

5556
echo "run patch package including newFile (case insensitive)"
56-
npx patch-package lodash --include newFile --case-sensitive-path-filtering
57+
patch-package lodash --include newFile --case-sensitive-path-filtering
5758

5859
echo "revert to the beginning"
5960
npx rimraf node_modules
@@ -63,13 +64,13 @@ echo "edit lodash's package.json"
6364
npx replace description patchPackageRulezLol node_modules/lodash/package.json
6465

6566
echo "check that the edit was ignored by default"
66-
if npx patch-package lodash
67+
if patch-package lodash
6768
then
6869
exit 1
6970
fi
7071

7172
echo "un-ingore the edit by specifying the empty string as regexp"
72-
npx patch-package lodash --exclude '^$'
73+
patch-package lodash --exclude '^$'
7374

7475
echo "SNAPSHOT: modified package.json"
7576
cat patches/lodash*

integration-tests/include-exclude-regex-relativity/include-exclude-regex-relativity.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,39 @@ set -e
33

44
echo "add patch-package"
55
yarn add $1
6+
alias patch-package=./node_modules/.bin/patch-package
67

78
echo "mutate words.js"
89
npx replace words patch-packages node_modules/lodash/words.js
910

1011
echo "patch-package includes words.js in a patch by default"
11-
npx patch-package lodash
12+
patch-package lodash
1213

1314
echo "patch-package doesn't include words.js if excluded with relative path"
14-
if npx patch-package lodash --exclude '^words' ; then
15+
if patch-package lodash --exclude '^words' ; then
1516
exit 1
1617
fi
1718

1819
echo "patch-package includes words.js if included with relative path"
19-
npx patch-package lodash --include '^words'
20+
patch-package lodash --include '^words'
2021

2122
echo "patch-package doesn't exclude words.js if excluded with node_modules path"
22-
npx patch-package lodash --exclude node_modules/lodash/words.js
23+
patch-package lodash --exclude node_modules/lodash/words.js
2324

2425
echo "patch-package doesn't include words.js if included with node_modules path"
25-
if npx patch-package lodash --include node_modules/lodash/words.js ; then
26+
if patch-package lodash --include node_modules/lodash/words.js ; then
2627
exit 1
2728
fi
2829

2930
echo "patch-package doesn't exclude words.js if excluded with lodash path"
30-
npx patch-package lodash --exclude lodash/words.js
31+
patch-package lodash --exclude lodash/words.js
3132

3233
echo "patch-package doesn't include words.js if included with lodash path"
33-
if npx patch-package lodash --include lodash/words.js ; then
34+
if patch-package lodash --include lodash/words.js ; then
3435
exit 1
3536
fi
3637

3738
echo "patch-package does exclude words.js if excluded without prefix"
38-
if npx patch-package lodash --exclude words.js ; then
39+
if patch-package lodash --exclude words.js ; then
3940
exit 1
4041
fi

0 commit comments

Comments
 (0)