Skip to content

Commit c52d018

Browse files
committed
simplify patch creation
1 parent 824e647 commit c52d018

31 files changed

+168
-462
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ echo "remove a file"
1111
rm node_modules/lodash/fp/__.js
1212

1313
echo "generate patch file"
14-
patch-package lodash
14+
npx patch-package lodash
1515

1616
echo "remove node_modules"
1717
rm -rf node_modules
1818

1919
echo "resintall and patch node_modules"
2020
yarn
21-
yarn patch-package
21+
npx patch-package
2222

2323
echo "check that the file was added"
2424
ls node_modules/lodash/newFile.md

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fi
1414
replace leftPad patchPackage node_modules/left-pad/index.js
1515

1616
echo 'but patch-package still works because it ignores scripts'
17-
patch-package left-pad
17+
npx patch-package left-pad
1818

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

integration-tests/happy-path-npm/__snapshots__/happy-path-npm.test.ts.snap

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
exports[`Test happy-path-npm: making patch 1`] = `
44
"SNAPSHOT: making patch
5-
☑ Creating temporary folder
6-
☑ Building clean node_modules with npm
7-
☑ Diffing your files with clean files
5+
✔ Creating temporary folder
6+
✔ Making tmp package.json
7+
✔ Installing [email protected] with npm
8+
✔ Diffing your files with clean files
89
✔ Created file patches/left-pad+1.1.3.patch
910
END SNAPSHOT"
1011
`;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ echo "replace pad with yarn in left-pad/index.js"
1313
replace pad npm node_modules/left-pad/index.js
1414

1515
echo "SNAPSHOT: making patch"
16-
patch-package left-pad
16+
npx patch-package left-pad
1717
echo "END SNAPSHOT"
1818

1919
echo "SNAPSHOT: the patch looks like this"

integration-tests/happy-path-yarn/__snapshots__/happy-path-yarn.test.ts.snap

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
exports[`Test happy-path-yarn: making patch 1`] = `
44
"SNAPSHOT: making patch
5-
☑ Creating temporary folder
6-
☑ Building clean node_modules with yarn
7-
☑ Diffing your files with clean files
5+
✔ Creating temporary folder
6+
✔ Making tmp package.json
7+
✔ Installing [email protected] with yarn
8+
✔ Diffing your files with clean files
89
✔ Created file patches/left-pad+1.1.3.patch
910
END SNAPSHOT"
1011
`;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ echo "replace pad with yarn in left-pad/index.js"
1111
replace pad yarn node_modules/left-pad/index.js
1212

1313
echo "SNAPSHOT: making patch"
14-
patch-package left-pad
14+
npx patch-package left-pad
1515
echo "END SNAPSHOT"
1616

1717
echo "SNAPSHOT: the patch looks like this"

integration-tests/ignore-whitespace/add-whitespace.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ const withWhitespace = lines
1313
)
1414
.join("\n")
1515

16-
const buf = new Buffer(withWhitespace)
16+
const buf = Buffer.from(withWhitespace)
1717

1818
fs.writeFileSync(file, buf)

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ replace 'a' 'patch-package' node_modules/alphabet/index.js
2121
node add-whitespace.js 2
2222

2323
echo "make patch file for line a"
24-
patch-package alphabet
24+
npx patch-package alphabet
2525

2626
echo "SNAPSHOT: line a changed"
2727
cat patches/alphabet*.patch
@@ -30,19 +30,19 @@ echo "END SNAPSHOT"
3030
echo "make sure the patch can be applied to clean files"
3131
rm -rf node_modules
3232
yarn
33-
patch-package
33+
npx patch-package
3434
grep patch-package node_modules/alphabet/index.js
3535

3636
echo "make sure the patch can be applied to dirty files"
3737
rm -rf node_modules
3838
yarn
3939
node add-whitespace.js
40-
patch-package
40+
npx patch-package
4141
grep patch-package node_modules/alphabet/index.js
4242

4343
echo "make sure the patch can be applied to dirty files with different whitespace"
4444
rm -rf node_modules
4545
yarn
4646
node add-whitespace.js 1
47-
patch-package
47+
npx patch-package
4848
grep patch-package node_modules/alphabet/index.js

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,44 @@ echo "remove a file"
1616
rm node_modules/lodash/fp/__.js
1717

1818
echo "run patch-package with only __.js included"
19-
patch-package lodash --include __
19+
npx patch-package lodash --include __
2020

2121
echo "SNAPSHOT: only __.js being deleted"
2222
cat patches/lodash*
2323
echo "END SNAPSHOT"
2424

2525
echo "run patch-package excluding the base files"
26-
patch-package lodash --exclude base
26+
npx patch-package lodash --exclude base
2727

2828
echo "SNAPSHOT: no base files"
2929
cat patches/lodash*
3030
echo "END SNAPSHOT"
3131

3232
echo "run patch-package including base and excluding clone"
33-
patch-package lodash --include base --exclude clone
33+
npx patch-package lodash --include base --exclude clone
3434

3535
echo "SNAPSHOT: only base files, no clone files"
3636
cat patches/lodash*
3737
echo "END SNAPSHOT"
3838

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

4242
echo "SNAPSHOT: exclude all but flip"
4343
cat patches/lodash*
4444
echo "END SNAPSHOT"
4545

4646
echo "run patch package including newfile (case insensitive)"
47-
patch-package lodash --include newfile
47+
npx patch-package lodash --include newfile
4848

4949
echo "run patch package including newfile (case sensitive)"
50-
if patch-package lodash --include newfile --case-sensitive-path-filtering
50+
if npx patch-package lodash --include newfile --case-sensitive-path-filtering
5151
then
5252
exit 1
5353
fi
5454

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

5858
echo "revet to the beginning"
5959
rimraf node_modules
@@ -63,13 +63,13 @@ echo "edit lodash's package.json"
6363
replace description patchPackageRulezLol node_modules/lodash/package.json
6464

6565
echo "check that the edit was ignored by default"
66-
if patch-package lodash
66+
if npx patch-package lodash
6767
then
6868
exit 1
6969
fi
7070

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

7474
echo "SNAPSHOT: modified package.json"
7575
cat patches/lodash*

integration-tests/resolve-relative-paths/__snapshots__/resolve-relative-paths.test.ts.snap

-14
This file was deleted.

integration-tests/resolve-relative-paths/local-package/index.js

-1
This file was deleted.

integration-tests/resolve-relative-paths/local-package/package.json

-6
This file was deleted.

integration-tests/resolve-relative-paths/package.json

-10
This file was deleted.

integration-tests/resolve-relative-paths/resolve-relative-paths.sh

-30
This file was deleted.

integration-tests/resolve-relative-paths/resolve-relative-paths.test.ts

-3
This file was deleted.

integration-tests/resolve-relative-paths/yarn.lock

-70
This file was deleted.

integration-tests/reverse-option/reverse-option.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ echo "remove a file"
1414
rm node_modules/lodash/fp/__.js
1515

1616
echo "make the patch file"
17-
yarn patch-package lodash
17+
npx patch-package lodash
1818

1919
echo "reinstall node modules"
2020
rm -rf node_modules
@@ -32,7 +32,7 @@ fi
3232
ls node_modules/lodash/fp/__.js
3333

3434
echo "apply the patch"
35-
yarn patch-package
35+
npx patch-package
3636

3737
echo "make sure the patch is applied"
3838
ls node_modules/lodash/newFile.md
@@ -43,7 +43,7 @@ fi
4343
grep patchPackage node_modules/lodash/_baseClamp.js
4444

4545
echo "apply the patch again to make sure it's an idempotent operation"
46-
yarn patch-package
46+
npx patch-package
4747

4848
echo "make sure the patch is still applied"
4949
ls node_modules/lodash/newFile.md
@@ -55,7 +55,7 @@ grep patchPackage node_modules/lodash/_baseClamp.js
5555

5656

5757
echo "unapply the patch"
58-
yarn patch-package --reverse
58+
npx patch-package --reverse
5959

6060
echo "make sure the patch is unapplied"
6161
if ls node_modules/lodash/newFile.md
@@ -69,7 +69,7 @@ fi
6969
ls node_modules/lodash/fp/__.js
7070

7171
echo "unapply the patch again to make sure it's an idempotent operation"
72-
yarn patch-package --reverse
72+
npx patch-package --reverse
7373

7474
echo "make sure the patch is still unapplied"
7575
if ls node_modules/lodash/newFile.md

integration-tests/scoped-package/scoped-package.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ echo "modify add.d.t.s"
1212
replace add patch-package node_modules/@types/lodash/add.d.ts
1313

1414
echo "patch-package can make patches for scoped packages"
15-
patch-package @types/lodash
15+
npx patch-package @types/lodash
1616

1717
echo "remove node_modules"
1818
rimraf node_modules

0 commit comments

Comments
 (0)