Skip to content

Commit febeb5b

Browse files
authored
Merge pull request ds300#170 from ds300/ignore-scripts
Ignore scripts when making patches
2 parents 899a489 + 8b9aa90 commit febeb5b

File tree

8 files changed

+521
-4
lines changed

8 files changed

+521
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Test ignores-scripts-when-making-patch: a patch file got produced 1`] = `
4+
"SNAPSHOT: a patch file got produced
5+
diff --git a/node_modules/naughty-package/postinstall.sh b/node_modules/naughty-package/postinstall.sh
6+
index 3784520..c4af29c 100755
7+
--- a/node_modules/naughty-package/postinstall.sh
8+
+++ b/node_modules/naughty-package/postinstall.sh
9+
@@ -1,4 +1,4 @@
10+
-# postinstall
11+
+# lol
12+
13+
# if we're running in the main repo is ok
14+
if ls ../patch-package ;
15+
END SNAPSHOT"
16+
`;
17+
18+
exports[`Test ignores-scripts-when-making-patch: the patch creation output should look normal 1`] = `
19+
"SNAPSHOT: the patch creation output should look normal
20+
patch-package 0.0.0
21+
• Creating temporary folder
22+
• Installing [email protected] with yarn
23+
• Diffing your files with clean files
24+
✔ Created file patches/naughty-package+1.0.0.patch
25+
END SNAPSHOT"
26+
`;
27+
28+
exports[`Test ignores-scripts-when-making-patch: there should be no stderr 1`] = `
29+
"SNAPSHOT: there should be no stderr
30+
END SNAPSHOT"
31+
`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# make sure errors stop the script
2+
set -e
3+
4+
echo "add patch-package"
5+
yarn add $1
6+
7+
npx replace postinstall lol node_modules/naughty-package/postinstall.sh
8+
9+
echo "SNAPSHOT: the patch creation output should look normal"
10+
(>&2 echo "SNAPSHOT: there should be no stderr")
11+
npx patch-package naughty-package
12+
echo "END SNAPSHOT"
13+
(>&2 echo "END SNAPSHOT")
14+
15+
echo "SNAPSHOT: a patch file got produced"
16+
cat patches/naughty-package+1.0.0.patch
17+
echo "END SNAPSHOT"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { runIntegrationTest } from "../runIntegrationTest"
2+
runIntegrationTest({
3+
projectName: "ignores-scripts-when-making-patch",
4+
shouldProduceSnapshots: true,
5+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "naughty-package",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"scripts": {
7+
"postinstall": "./postinstall.sh"
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# postinstall
2+
3+
# if we're running in the main repo is ok
4+
if ls ../patch-package ;
5+
then
6+
exit 0
7+
fi
8+
# if we are installed alone then fail
9+
exit 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "ignores-scripts-when-making-patch",
3+
"version": "1.0.0",
4+
"description": "integration test for patch-package",
5+
"main": "index.js",
6+
"author": "",
7+
"license": "ISC",
8+
"dependencies": {
9+
"naughty-package": "file:./naughty-package",
10+
"replace": "^1.1.1"
11+
}
12+
}

0 commit comments

Comments
 (0)