Skip to content

Commit b49e322

Browse files
committed
feat: add unset input.
1 parent e0c921e commit b49e322

File tree

7 files changed

+582
-116
lines changed

7 files changed

+582
-116
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ jobs:
8484
- run: echo "os - ${{ steps.info2.outputs.os }}"
8585
- run: echo "cpu - ${{ steps.info2.outputs.cpu }}"
8686

87+
- name: delete nested values
88+
uses: ./
89+
with:
90+
unset: scripts.watch,lint-staged,devDependencies
91+
92+
- run: cat package.json
93+
8794
- name: Generate Changelog
8895
id: changelog
8996
uses: jaywcjlove/changelog-generator@main

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,48 @@ Read and modify the contents of `package.json`.
4747
- run: echo "author - ${{ steps.info.outputs.author }}"
4848
```
4949
50+
### delete nested values
51+
52+
```json
53+
{
54+
"name": "github-action-package",
55+
"author": "jaywcjlove",
56+
"repository": {
57+
"type": "git",
58+
"url": "https://github.com/jaywcjlove/github-action-package"
59+
},
60+
"keywords": [
61+
"actions",
62+
"package"
63+
]
64+
}
65+
```
66+
67+
```yml
68+
- name: package.json info
69+
uses: jaywcjlove/github-action-package@main
70+
with:
71+
unset: repository.type,repository.url,keywords
72+
```
73+
74+
Output:
75+
76+
```json
77+
{
78+
"name": "github-action-package",
79+
"author": "jaywcjlove",
80+
"repository": {}
81+
}
82+
```
83+
5084
## Inputs
5185

5286
- `path` The path of the `package.json` file. Default: `package.json`
5387
- `data` json data for changing `package.json`. Default: `{}`
5488
- `rename` Used to change "name" data in "package.json".
5589
- `version` Used to change "`version`" data in "package.json".
5690
- `description` Used to change "`description`" data in "package.json".
91+
- `unset` delete "Object" nested values in "package.json".
5792

5893
### Output Parameters
5994

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ inputs:
2828
description: Used to change "`description`" data in "package.json".
2929
required: false
3030

31+
unset:
32+
description: delete "Object" nested values
33+
required: false
34+
3135
outputs:
3236
name:
3337
description: 'name field in package.json, The name of the package.'

0 commit comments

Comments
 (0)