-
-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add integration test for yarn workspaces
- Loading branch information
Showing
7 changed files
with
585 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
integration-tests/yarn-workspaces/add-postinstall-commands.js
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,24 @@ | ||
const fs = require("fs") | ||
|
||
function addPostinstall(packageJsonPath) { | ||
const json = JSON.parse(fs.readFileSync(packageJsonPath)) | ||
fs.writeFileSync( | ||
packageJsonPath, | ||
JSON.stringify( | ||
{ | ||
...json, | ||
scripts: { | ||
...json.scripts, | ||
postinstall: "yarn patch-package", | ||
}, | ||
}, | ||
null, | ||
" ", | ||
), | ||
) | ||
} | ||
|
||
Array.prototype.slice | ||
.call(process.argv, 2) | ||
.filter(x => !x.match(/node_modules/)) | ||
.map(addPostinstall) |
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,19 @@ | ||
{ | ||
"name": "yarn-workspaces", | ||
"version": "1.0.0", | ||
"private": true, | ||
"description": "integration test for patch-package", | ||
"main": "index.js", | ||
"author": "", | ||
"license": "ISC", | ||
"workspaces": { | ||
"packages": [ | ||
"packages/*" | ||
] | ||
}, | ||
"dependencies": { | ||
"postinstall-postinstall": "^2.0.0", | ||
"replace": "^1.1.0", | ||
"rimraf": "^2.6.3" | ||
} | ||
} |
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,13 @@ | ||
{ | ||
"name": "a", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"patch-package": "../../node_modules/.bin/patch-package" | ||
}, | ||
"dependencies": { | ||
"left-pad": "^1.3.0", | ||
"postinstall-postinstall": "^2.0.0" | ||
} | ||
} |
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,13 @@ | ||
{ | ||
"name": "b", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"patch-package": "../../node_modules/.bin/patch-package" | ||
}, | ||
"dependencies": { | ||
"left-pad": "1.2.0", | ||
"postinstall-postinstall": "^2.0.0" | ||
} | ||
} |
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,51 @@ | ||
# make sure errors stop the script | ||
set -e | ||
|
||
echo "tarball $1" | ||
echo "add patch-package to root" | ||
yarn add $1 --ignore-workspace-root-check | ||
|
||
echo "set up postinstall scripts" | ||
node ./add-postinstall-commands.js package.json packages/a/package.json packages/b/package.json | ||
|
||
echo "modify hoisted left-pad" | ||
npx replace leftPad patch-package node_modules/left-pad/index.js | ||
|
||
echo "create patch file" | ||
npx patch-package left-pad | ||
|
||
echo "modify unhoisted left-pad" | ||
cd packages/a | ||
npx replace leftPad patch-package node_modules/left-pad/index.js | ||
|
||
echo "create patch file" | ||
npx patch-package left-pad | ||
|
||
echo "go back to root" | ||
cd ../../ | ||
|
||
echo "delete all node modules" | ||
rimraf **/node_modules | ||
|
||
echo "execute yarn from root" | ||
yarn | ||
|
||
echo "hoisted left-pad was patched" | ||
grep patch-package node_modules/left-pad/index.js | ||
|
||
echo "unhoisted left-pad was patched" | ||
grep patch-package packages/a/node_modules/left-pad/index.js | ||
|
||
echo "delete all node modules" | ||
rimraf **/node_modules | ||
|
||
echo "execute yarn from a" | ||
cd packages/a | ||
yarn | ||
cd ../../ | ||
|
||
echo "hoisted left-pad was patched" | ||
grep patch-package node_modules/left-pad/index.js | ||
|
||
echo "unhoisted left-pad was patched" | ||
grep patch-package packages/a/node_modules/left-pad/index.js |
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,5 @@ | ||
import { runIntegrationTest } from "../runIntegrationTest" | ||
runIntegrationTest({ | ||
projectName: "yarn-workspaces", | ||
shouldProduceSnapshots: false, | ||
}) |
Oops, something went wrong.