Skip to content

Ignore scripts when making patches #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Test ignores-scripts-when-making-patch: a patch file got produced 1`] = `
"SNAPSHOT: a patch file got produced
diff --git a/node_modules/naughty-package/postinstall.sh b/node_modules/naughty-package/postinstall.sh
index 3784520..c4af29c 100755
--- a/node_modules/naughty-package/postinstall.sh
+++ b/node_modules/naughty-package/postinstall.sh
@@ -1,4 +1,4 @@
-# postinstall
+# lol

# if we're running in the main repo is ok
if ls ../patch-package ;
END SNAPSHOT"
`;

exports[`Test ignores-scripts-when-making-patch: the patch creation output should look normal 1`] = `
"SNAPSHOT: the patch creation output should look normal
patch-package 0.0.0
• Creating temporary folder
• Installing [email protected] with yarn
• Diffing your files with clean files
✔ Created file patches/naughty-package+1.0.0.patch
END SNAPSHOT"
`;

exports[`Test ignores-scripts-when-making-patch: there should be no stderr 1`] = `
"SNAPSHOT: there should be no stderr
END SNAPSHOT"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# make sure errors stop the script
set -e

echo "add patch-package"
yarn add $1

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

echo "SNAPSHOT: the patch creation output should look normal"
(>&2 echo "SNAPSHOT: there should be no stderr")
npx patch-package naughty-package
echo "END SNAPSHOT"
(>&2 echo "END SNAPSHOT")

echo "SNAPSHOT: a patch file got produced"
cat patches/naughty-package+1.0.0.patch
echo "END SNAPSHOT"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { runIntegrationTest } from "../runIntegrationTest"
runIntegrationTest({
projectName: "ignores-scripts-when-making-patch",
shouldProduceSnapshots: true,
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "naughty-package",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"postinstall": "./postinstall.sh"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# postinstall

# if we're running in the main repo is ok
if ls ../patch-package ;
then
exit 0
fi
# if we are installed alone then fail
exit 1
12 changes: 12 additions & 0 deletions integration-tests/ignores-scripts-when-making-patch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "ignores-scripts-when-making-patch",
"version": "1.0.0",
"description": "integration test for patch-package",
"main": "index.js",
"author": "",
"license": "ISC",
"dependencies": {
"naughty-package": "file:./naughty-package",
"replace": "^1.1.1"
}
}
Loading