Skip to content

Commit 21ec475

Browse files
author
David Sheldrick
committed
add integration test for scripts deletion
1 parent f7eaf8e commit 21ec475

File tree

5 files changed

+136
-0
lines changed

5 files changed

+136
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Test delete-scripts: a patch file got produced 1`] = `
4+
"SNAPSHOT: a patch file got produced
5+
diff --git a/node_modules/left-pad/index.js b/node_modules/left-pad/index.js
6+
index e90aec3..f2b8b0a 100644
7+
--- a/node_modules/left-pad/index.js
8+
+++ b/node_modules/left-pad/index.js
9+
@@ -4,7 +4,7 @@
10+
* To Public License, Version 2, as published by Sam Hocevar. See
11+
* http://www.wtfpl.net/ for more details. */
12+
'use strict';
13+
-module.exports = leftPad;
14+
+module.exports = patchPackage;
15+
16+
var cache = [
17+
'',
18+
@@ -19,7 +19,7 @@ var cache = [
19+
' '
20+
];
21+
22+
-function leftPad (str, len, ch) {
23+
+function patchPackage (str, len, ch) {
24+
// convert \`str\` to a \`string\`
25+
str = str + '';
26+
// \`len\` is the \`pad\`'s length now
27+
END SNAPSHOT"
28+
`;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { runShellTest } from "./shellTests"
2+
3+
runShellTest("delete-scripts")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
set -e
2+
3+
echo 'install without error because package.json is sanitized'
4+
yarn add $1
5+
6+
echo 'unsnitize package.json'
7+
replace '<<PREINSTALL>>' preinstall package.json
8+
9+
echo 'install fails because preinstall hook is bad'
10+
if yarn; then
11+
exit 1
12+
fi
13+
14+
replace leftPad patchPackage node_modules/left-pad/index.js
15+
16+
echo 'but patch-package still works because it ignores scripts'
17+
patch-package left-pad
18+
19+
echo "SNAPSHOT: a patch file got produced"
20+
cat patches/left-pad*.patch
21+
echo "END SNAPSHOT"

test/delete-scripts/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "delete-scripts",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"scripts": {
7+
"<<PREINSTALL>>": "exit 1"
8+
},
9+
"dependencies": {
10+
"left-pad": "^1.3.0",
11+
"replace": "^1.0.0"
12+
}
13+
}

test/delete-scripts/yarn.lock

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
ansi-styles@~1.0.0:
6+
version "1.0.0"
7+
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.0.0.tgz#cb102df1c56f5123eab8b67cd7b98027a0279178"
8+
9+
balanced-match@^1.0.0:
10+
version "1.0.0"
11+
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
12+
13+
brace-expansion@^1.1.7:
14+
version "1.1.11"
15+
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
16+
dependencies:
17+
balanced-match "^1.0.0"
18+
concat-map "0.0.1"
19+
20+
chalk@~0.4.0:
21+
version "0.4.0"
22+
resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.4.0.tgz#5199a3ddcd0c1efe23bc08c1b027b06176e0c64f"
23+
dependencies:
24+
ansi-styles "~1.0.0"
25+
has-color "~0.1.0"
26+
strip-ansi "~0.1.0"
27+
28+
colors@1.2.4:
29+
version "1.2.4"
30+
resolved "https://registry.yarnpkg.com/colors/-/colors-1.2.4.tgz#e0cb41d3e4b20806b3bfc27f4559f01b94bc2f7c"
31+
32+
concat-map@0.0.1:
33+
version "0.0.1"
34+
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
35+
36+
has-color@~0.1.0:
37+
version "0.1.7"
38+
resolved "https://registry.yarnpkg.com/has-color/-/has-color-0.1.7.tgz#67144a5260c34fc3cca677d041daf52fe7b78b2f"
39+
40+
left-pad@^1.3.0:
41+
version "1.3.0"
42+
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.3.0.tgz#5b8a3a7765dfe001261dde915589e782f8c94d1e"
43+
44+
minimatch@3.0.4:
45+
version "3.0.4"
46+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
47+
dependencies:
48+
brace-expansion "^1.1.7"
49+
50+
nomnom@1.8.1:
51+
version "1.8.1"
52+
resolved "https://registry.yarnpkg.com/nomnom/-/nomnom-1.8.1.tgz#2151f722472ba79e50a76fc125bb8c8f2e4dc2a7"
53+
dependencies:
54+
chalk "~0.4.0"
55+
underscore "~1.6.0"
56+
57+
replace@^1.0.0:
58+
version "1.0.0"
59+
resolved "https://registry.yarnpkg.com/replace/-/replace-1.0.0.tgz#da5235cc6d64d5c3a74e4ef73b487aad0f79a74b"
60+
dependencies:
61+
colors "1.2.4"
62+
minimatch "3.0.4"
63+
nomnom "1.8.1"
64+
65+
strip-ansi@~0.1.0:
66+
version "0.1.1"
67+
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.1.1.tgz#39e8a98d044d150660abe4a6808acf70bb7bc991"
68+
69+
underscore@~1.6.0:
70+
version "1.6.0"
71+
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.6.0.tgz#8b38b10cacdef63337b8b24e4ff86d45aea529a8"

0 commit comments

Comments
 (0)