Skip to content

Commit

Permalink
feat: add --git-ignore option
Browse files Browse the repository at this point in the history
When set, excludes git ignored files from patch creation.
  • Loading branch information
gomain committed Sep 10, 2020
1 parent 50f73bd commit e1d70fa
Show file tree
Hide file tree
Showing 7 changed files with 685 additions and 3 deletions.
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"
}
}

0 comments on commit e1d70fa

Please sign in to comment.