Skip to content

Commit 28c55a1

Browse files
committed
feat(cli): Install wrapper bin/ox(lint|fmt) for oxc-vscode
1 parent 5844065 commit 28c55a1

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

packages/cli/bin/oxfmt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env node
2+
3+
// LSP-only wrapper for oxfmt.
4+
// This enables IDE extensions (e.g., oxc-vscode) to discover and start the LSP server.
5+
// Binary resolution follows the same approach as `src/resolve-fmt.ts`.
6+
7+
if (!process.argv.includes('--lsp')) {
8+
console.error('This oxfmt wrapper is for IDE extension use only (--lsp mode).');
9+
console.error('To format your code, run: vp fmt');
10+
process.exit(1);
11+
}
12+
13+
import { createRequire } from 'node:module';
14+
15+
const require = createRequire(import.meta.url);
16+
const oxfmtBin = require.resolve('oxfmt/bin/oxfmt');
17+
18+
await import(oxfmtBin);

packages/cli/bin/oxlint

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
// LSP-only wrapper for oxlint.
4+
// This enables IDE extensions (e.g., oxc-vscode) to discover and start the LSP server.
5+
// Binary resolution follows the same approach as `src/resolve-lint.ts`.
6+
7+
if (!process.argv.includes('--lsp')) {
8+
console.error('This oxlint wrapper is for IDE extension use only (--lsp mode).');
9+
console.error('To lint your code, run: vp lint');
10+
process.exit(1);
11+
}
12+
13+
import { createRequire } from 'node:module';
14+
import { dirname, join } from 'node:path';
15+
16+
const require = createRequire(import.meta.url);
17+
const oxlintMainPath = require.resolve('oxlint');
18+
const oxlintBin = join(dirname(dirname(oxlintMainPath)), 'bin', 'oxlint');
19+
20+
await import(oxlintBin);

packages/cli/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"name": "vite-plus",
33
"version": "0.0.0",
44
"bin": {
5+
"oxfmt": "./bin/oxfmt",
6+
"oxlint": "./bin/oxlint",
57
"vp": "./bin/vp"
68
},
79
"files": [

0 commit comments

Comments
 (0)