Skip to content
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

feat: add --git-ignore option #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ team.
- `--patch-dir`

Specify the name for the directory in which to put the patch files.

- `--git-ignore`

By default, patch-package creates patches disregarding your git-ignore
settings. Set this option to exclude git-ignored files from patches.

#### Nested packages

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# make sure errors stop the script
set -e

echo "add patch-package"
yarn add $1

echo "intitialize a git repo"
git init

addedFileName=addedFileName.md
addedFile=node_modules/lodash/$addedFileName
addedIgnoredFileName=addedIgnoredFileName.md
addedIgnoredFile=node_modules/lodash/$addedIgnoredFileName
removedFileName=fp/__.js
removedFile=node_modules/lodash/$removedFileName
removedIgnoredFileName=fp.js
removedIgnoredFile=node_modules/lodash/$removedIgnoredFileName

echo "add not ignored file"
echo "this should be patched" > $addedFile

echo "add ignored file"
echo "this should be ginored" > $addedIgnoredFile

echo "remove a not ignored file"
rm $removedFile

echo "remove an ignored file"
rm $removedIgnoredFile

echo "config .gitignore"
echo $addedIgnoredFileName > .gitignore
echo $removedIgnoredFileName >> .gitignore

echo "generate patch file"
npx patch-package lodash --git-ignore

echo "remove node_modules"
rm -rf node_modules

echo "resintall and patch node_modules"
yarn
npx patch-package

echo "check that not ignored file was added"
ls $addedFile

echo "check that ignored file was not added"
if ls $addedIgnoredFile
then
exit 1
fi

echo "check that not ignored file was removed"
if ls $removedFile
then
exit 1
fi

echo "check that ignored file was not removed"
ls $removedIgnoredFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { runIntegrationTest } from "../runIntegrationTest"

runIntegrationTest({
projectName: "exclude-git-ignored-files",
shouldProduceSnapshots: false,
})
14 changes: 14 additions & 0 deletions integration-tests/exclude-git-ignored-files/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "exclude-git-ignored-files",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"lodash": "4.17.4"
}
}