-
-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Hi !
If I run the following script :
#!/usr/bin/env bash
set -euo pipefail
setup() {
git clone https://github.com/open-xml-templating/docxtemplater.git
cd docxtemplater
npm install
}
# setup needs to be run for the setup
./node_modules/.bin/prettier --write --cache --experimental-cli "*.md"
ls node_modules/.cache/prettier/.prettier-caches/*.json -lah
jq . <node_modules/.cache/prettier/.prettier-caches/*.json
./node_modules/.bin/prettier --write --cache --experimental-cli README.md
ls node_modules/.cache/prettier/.prettier-caches/*.json -lah
jq . <node_modules/.cache/prettier/.prettier-caches/*.json
I get following output :
-rw-r--r-- 1 edgar edgar 287 Nov 25 09:14 node_modules/.cache/prettier/.prettier-caches/bec0b1d736d4fe087b546a617a1ebae139f8a932.json
{
"7e4df3d5c8fc5596b9517b0748bd71e8aa8fb5e6": {
"files": {
"README.md": [
"KQ2A3d16X1tSgG6DXe9Cjh5Dldg=",
true
],
"SECURITY.md": [
"UJf4UVT23vLYi1NLDIHTzeXYxPI=",
true
],
"LICENSE.md": [
"DWOqhR+uc8Ua3WukNo9g1+9+sRE=",
true
],
"CHANGELOG.md": [
"HVx6/XmNGvGz4Pg2FHa4whufm84=",
true
]
},
"modified": 1764058489782
}
}
-rw-r--r-- 1 edgar edgar 131 Nov 25 09:14 node_modules/.cache/prettier/.prettier-caches/bec0b1d736d4fe087b546a617a1ebae139f8a932.json
{
"21796ba460ee7a877e1ef710c2ef3d96df1f2adf": {
"files": {
"README.md": [
"KQ2A3d16X1tSgG6DXe9Cjh5Dldg=",
true
]
},
"modified": 1764058490211
}
}
In the output, you can see that after the second prettier run, only the "README.md" file is present in the cache.
It seems that the cache is completely dropped and then rewritten at each run.
I would expect existing files (like CHANGELOG.md, LICENSE.md, to still be in the cache after the second prettier run).
This issue seems to be specific to the --experimental-cli flag.
Without --experimental-cli, it wors well :
./node_modules/.bin/prettier --write --cache "*.md"
ls node_modules/.cache/prettier/.prettier-cache -lah
./node_modules/.bin/prettier --write --cache README.md
ls node_modules/.cache/prettier/.prettier-cache -lah
Outputs :
-rw-r--r-- 1 edgar edgar 19K Nov 25 09:29 node_modules/.cache/prettier/.prettier-cache
-rw-r--r-- 1 edgar edgar 19K Nov 25 09:29 node_modules/.cache/prettier/.prettier-cache
The reproduction I created was simplified and somewhat artificial. In my real world usecase, I have submodules and sometimes I run prettier just for the current module, sometimes for the whole folder, and sometimes just for the current file (in my editor) and the cache doesn't persist if I run it on a subset of files.