-
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #474 from ds300/multiple-patches
Support loading multiple patches.
- Loading branch information
Showing
133 changed files
with
5,002 additions
and
671 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
on: [push, pull_request] | ||
on: | ||
pull_request: | ||
push: | ||
branches: [master] | ||
name: Test | ||
jobs: | ||
test: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
integration-tests/append-patches/__snapshots__/append-patches.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Test append-patches: 00: basic patch file 1`] = ` | ||
"SNAPSHOT: basic patch file | ||
left-pad+1.3.0.patch | ||
END SNAPSHOT" | ||
`; | ||
|
||
exports[`Test append-patches: 01: after appending a patch file 1`] = ` | ||
"SNAPSHOT: after appending a patch file | ||
left-pad+1.3.0+001+initial.patch | ||
left-pad+1.3.0+002+MillionDollars.patch | ||
END SNAPSHOT" | ||
`; | ||
|
||
exports[`Test append-patches: 02: the second patch file should go from patch-package to a million dollars 1`] = ` | ||
"SNAPSHOT: the second patch file should go from patch-package to a million dollars | ||
diff --git a/node_modules/left-pad/index.js b/node_modules/left-pad/index.js | ||
index a409e14..73d2a7c 100644 | ||
--- a/node_modules/left-pad/index.js | ||
+++ b/node_modules/left-pad/index.js | ||
@@ -3,7 +3,7 @@ | ||
* and/or modify it under the terms of the Do What The Fuck You Want | ||
* To Public License, Version 2, as published by Sam Hocevar. See | ||
* http://www.wtfpl.net/ for more details. */ | ||
-'use patch-package'; | ||
+'use a million dollars'; | ||
module.exports = leftPad; | ||
var cache = [ | ||
END SNAPSHOT" | ||
`; | ||
|
||
exports[`Test append-patches: 03: creating a first patch file with --append 1`] = ` | ||
"SNAPSHOT: creating a first patch file with --append | ||
left-pad+1.3.0+001+FirstPatch.patch | ||
END SNAPSHOT" | ||
`; | ||
|
||
exports[`Test append-patches: 04: the squashed patch file should go from use strict to a million dollars 1`] = ` | ||
"SNAPSHOT: the squashed patch file should go from use strict to a million dollars | ||
diff --git a/node_modules/left-pad/index.js b/node_modules/left-pad/index.js | ||
index e90aec3..73d2a7c 100644 | ||
--- a/node_modules/left-pad/index.js | ||
+++ b/node_modules/left-pad/index.js | ||
@@ -3,7 +3,7 @@ | ||
* and/or modify it under the terms of the Do What The Fuck You Want | ||
* To Public License, Version 2, as published by Sam Hocevar. See | ||
* http://www.wtfpl.net/ for more details. */ | ||
-'use strict'; | ||
+'use a million dollars'; | ||
module.exports = leftPad; | ||
var cache = [ | ||
END SNAPSHOT" | ||
`; | ||
|
||
exports[`Test append-patches: 05: after appending a billion dollars 1`] = ` | ||
"SNAPSHOT: after appending a billion dollars | ||
left-pad+1.3.0+001+FirstPatch.patch | ||
left-pad+1.3.0+002+BillionDollars.patch | ||
END SNAPSHOT" | ||
`; | ||
|
||
exports[`Test append-patches: 06: after updating the appended patch file to a TRILLION dollars 1`] = ` | ||
"SNAPSHOT: after updating the appended patch file to a TRILLION dollars | ||
diff --git a/node_modules/left-pad/index.js b/node_modules/left-pad/index.js | ||
index 73d2a7c..f53ea10 100644 | ||
--- a/node_modules/left-pad/index.js | ||
+++ b/node_modules/left-pad/index.js | ||
@@ -3,7 +3,7 @@ | ||
* and/or modify it under the terms of the Do What The Fuck You Want | ||
* To Public License, Version 2, as published by Sam Hocevar. See | ||
* http://www.wtfpl.net/ for more details. */ | ||
-'use a million dollars'; | ||
+'use a trillion dollars'; | ||
module.exports = leftPad; | ||
var cache = [ | ||
END SNAPSHOT" | ||
`; | ||
|
||
exports[`Test append-patches: 07: patch-package fails when a patch in the sequence is invalid 1`] = ` | ||
"SNAPSHOT: patch-package fails when a patch in the sequence is invalid | ||
patch-package 0.0.0 | ||
• Creating temporary folder | ||
• Installing [email protected] with npm | ||
• Diffing your files with clean files | ||
Failed to apply patch left-pad+1.3.0+001+FirstPatch.patch to left-pad | ||
END SNAPSHOT" | ||
`; | ||
|
||
exports[`Test append-patches: 08: --append is not compatible with --create-issue 1`] = ` | ||
"SNAPSHOT: --append is not compatible with --create-issue | ||
patch-package 0.0.0 | ||
--create-issue is not compatible with --append. | ||
END SNAPSHOT" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" |
4 changes: 2 additions & 2 deletions
4
...atch-files/delete-old-patch-files.test.ts → ...sts/append-patches/append-patches.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { runIntegrationTest } from "../runIntegrationTest" | ||
runIntegrationTest({ | ||
projectName: "delete-old-patch-files", | ||
shouldProduceSnapshots: false, | ||
projectName: "append-patches", | ||
shouldProduceSnapshots: true, | ||
}) |
Oops, something went wrong.