Skip to content

Commit 90e037d

Browse files
Copilotntotten
andcommitted
Add test fixture and documentation for custom executable
Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
1 parent c180d29 commit 90e037d

7 files changed

Lines changed: 51 additions & 0 deletions

File tree

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,32 @@ Supply a custom path to the prettier module. This path should be to the module f
284284

285285
**Disabled on untrusted workspaces**
286286

287+
#### prettier.customExecutable
288+
289+
Use a custom executable to run Prettier. This is useful for Docker-centric workspaces where Prettier runs inside a container. Specify the full command including any arguments. The command will be executed with Prettier arguments appended.
290+
291+
Example for Docker:
292+
293+
```json
294+
{
295+
"prettier.customExecutable": "docker compose exec -T app node_modules/.bin/prettier"
296+
}
297+
```
298+
299+
Example with a wrapper script:
300+
301+
```json
302+
{
303+
"prettier.customExecutable": "./scripts/prettier-wrapper.sh"
304+
}
305+
```
306+
307+
When `prettier.customExecutable` is specified, it takes precedence over `prettier.prettierPath`. If you need to specify where Prettier is located for the custom executable, you can also set `prettier.prettierPath` and it will be used by the custom executable.
308+
309+
**Note:** The custom executable must accept Prettier CLI arguments and behave like the Prettier CLI. Input is provided via stdin and output is expected on stdout.
310+
311+
**Disabled on untrusted workspaces**
312+
287313
#### prettier.resolveGlobalModules (default: `false`)
288314

289315
When enabled, this extension will attempt to use global npm or yarn modules if local modules cannot be resolved.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": true,
3+
"singleQuote": false,
4+
"trailingComma": "es5"
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"prettier.customExecutable": "./wrapper.sh"
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "test-custom-executable",
3+
"version": "1.0.0",
4+
"private": true,
5+
"devDependencies": {
6+
"prettier": "3.4.2"
7+
}
8+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const x={a:1,b:2,c:3};
2+
function foo(a,b,c){return a+b+c}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
# Simple wrapper script for testing custom executable functionality
3+
# This simulates running prettier through an external command (like docker)
4+
exec "$@"

test-fixtures/test.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
},
6363
{
6464
"path": "monorepo-subfolder"
65+
},
66+
{
67+
"path": "custom-executable"
6568
}
6669
],
6770
"settings": {

0 commit comments

Comments
 (0)