Skip to content

Commit e0e1629

Browse files
authored
docs(config): new features (#707)
* docs(config): new features * fix: grammar
1 parent c094dc2 commit e0e1629

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

docs/cli/config.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,54 @@ The global configuration file is located at one of the following locations:
2424

2525
Set the config key to the value provided.
2626

27+
Without the `--json` flag, it parses the value as plain string:
28+
29+
```sh
30+
pnpm config set --location=project nodeVersion 22.0.0
31+
```
32+
33+
With the `--json` flag, it parses the value as JSON:
34+
35+
```sh
36+
pnpm config set --location=project --json nodeVersion '"22.0.0"'
37+
```
38+
39+
The `--json` flag also allows `pnpm config set` to create arrays and objects:
40+
41+
```sh
42+
pnpm config set --location=project --json onlyBuiltDependencies '["react", "react-dom"]'
43+
pnpm config set --location=project --json catalog '{ "react": "19" }'
44+
```
45+
46+
The `set` command does not accept a property path.
47+
2748
### get <key>
2849

2950
Print the config value for the provided key.
3051

52+
The `key` can be a simple key:
53+
54+
```sh
55+
pnpm config get nodeVersion
56+
pnpm config get --json nodeVersion
57+
pnpm config get --json packageExtensions
58+
pnpm config get --json onlyBuiltDependencies
59+
pnpm config get --json catalog
60+
```
61+
62+
It can also be a property path:
63+
64+
```sh
65+
pnpm config get 'packageExtensions["@babel/parser"].peerDependencies["@babel/types"]'
66+
pnpm config get --json 'packageExtensions["@babel/parser"].peerDependencies["@babel/types"]'
67+
pnpm config get 'onlyBuiltDependencies[0]'
68+
pnpm config get --json 'onlyBuiltDependencies[0]'
69+
pnpm config get catalog.react
70+
pnpm config get --json catalog.react
71+
```
72+
73+
The syntax of the property path emulates JavaScript property paths.
74+
3175
### delete <key>
3276

3377
Remove the config key from the config file.
@@ -50,5 +94,4 @@ When set to `global`, the performance is the same as setting the `--global` opti
5094

5195
### --json
5296

53-
Show all the config settings in JSON format.
54-
97+
Make `get` and `list` show all the config settings in JSON format and make `set` parse the value as JSON.

0 commit comments

Comments
 (0)