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"

0 commit comments

Comments
 (0)