File tree Expand file tree Collapse file tree 7 files changed +585
-0
lines changed
integration-tests/yarn-workspaces Expand file tree Collapse file tree 7 files changed +585
-0
lines changed Original file line number Diff line number Diff line change
1
+ const fs = require ( "fs" )
2
+
3
+ function addPostinstall ( packageJsonPath ) {
4
+ const json = JSON . parse ( fs . readFileSync ( packageJsonPath ) )
5
+ fs . writeFileSync (
6
+ packageJsonPath ,
7
+ JSON . stringify (
8
+ {
9
+ ...json ,
10
+ scripts : {
11
+ ...json . scripts ,
12
+ postinstall : "yarn patch-package" ,
13
+ } ,
14
+ } ,
15
+ null ,
16
+ " " ,
17
+ ) ,
18
+ )
19
+ }
20
+
21
+ Array . prototype . slice
22
+ . call ( process . argv , 2 )
23
+ . filter ( x => ! x . match ( / n o d e _ m o d u l e s / ) )
24
+ . map ( addPostinstall )
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " yarn-workspaces" ,
3
+ "version" : " 1.0.0" ,
4
+ "private" : true ,
5
+ "description" : " integration test for patch-package" ,
6
+ "main" : " index.js" ,
7
+ "author" : " " ,
8
+ "license" : " ISC" ,
9
+ "workspaces" : {
10
+ "packages" : [
11
+ " packages/*"
12
+ ]
13
+ },
14
+ "dependencies" : {
15
+ "postinstall-postinstall" : " ^2.0.0" ,
16
+ "replace" : " ^1.1.0" ,
17
+ "rimraf" : " ^2.6.3"
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " a" ,
3
+ "version" : " 1.0.0" ,
4
+ "main" : " index.js" ,
5
+ "license" : " MIT" ,
6
+ "scripts" : {
7
+ "patch-package" : " ../../node_modules/.bin/patch-package"
8
+ },
9
+ "dependencies" : {
10
+ "left-pad" : " ^1.3.0" ,
11
+ "postinstall-postinstall" : " ^2.0.0"
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " b" ,
3
+ "version" : " 1.0.0" ,
4
+ "main" : " index.js" ,
5
+ "license" : " MIT" ,
6
+ "scripts" : {
7
+ "patch-package" : " ../../node_modules/.bin/patch-package"
8
+ },
9
+ "dependencies" : {
10
+ "left-pad" : " 1.2.0" ,
11
+ "postinstall-postinstall" : " ^2.0.0"
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ # make sure errors stop the script
2
+ set -e
3
+
4
+ echo " tarball $1 "
5
+ echo " add patch-package to root"
6
+ yarn add $1 --ignore-workspace-root-check
7
+
8
+ echo " set up postinstall scripts"
9
+ node ./add-postinstall-commands.js package.json packages/a/package.json packages/b/package.json
10
+
11
+ echo " modify hoisted left-pad"
12
+ npx replace leftPad patch-package node_modules/left-pad/index.js
13
+
14
+ echo " create patch file"
15
+ npx patch-package left-pad
16
+
17
+ echo " modify unhoisted left-pad"
18
+ cd packages/a
19
+ npx replace leftPad patch-package node_modules/left-pad/index.js
20
+
21
+ echo " create patch file"
22
+ npx patch-package left-pad
23
+
24
+ echo " go back to root"
25
+ cd ../../
26
+
27
+ echo " delete all node modules"
28
+ rimraf ** /node_modules
29
+
30
+ echo " execute yarn from root"
31
+ yarn
32
+
33
+ echo " hoisted left-pad was patched"
34
+ grep patch-package node_modules/left-pad/index.js
35
+
36
+ echo " unhoisted left-pad was patched"
37
+ grep patch-package packages/a/node_modules/left-pad/index.js
38
+
39
+ echo " delete all node modules"
40
+ rimraf ** /node_modules
41
+
42
+ echo " execute yarn from a"
43
+ cd packages/a
44
+ yarn
45
+ cd ../../
46
+
47
+ echo " hoisted left-pad was patched"
48
+ grep patch-package node_modules/left-pad/index.js
49
+
50
+ echo " unhoisted left-pad was patched"
51
+ grep patch-package packages/a/node_modules/left-pad/index.js
Original file line number Diff line number Diff line change
1
+ import { runIntegrationTest } from "../runIntegrationTest"
2
+ runIntegrationTest ( {
3
+ projectName : "yarn-workspaces" ,
4
+ shouldProduceSnapshots : false ,
5
+ } )
You can’t perform that action at this time.
0 commit comments