Skip to content

Commit 2da4246

Browse files
committed
fix(cli,editor): Add env.VITE_PLUS_VERSION for oxlint and oxfmt
1 parent bf2bbce commit 2da4246

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

packages/cli/bin/oxfmt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ if (!process.argv.includes('--lsp')) {
1212

1313
import { createRequire } from 'node:module';
1414
import { pathToFileURL } from 'node:url';
15+
import pkg from '../package.json' with { type: 'json' };
1516

1617
const require = createRequire(import.meta.url);
1718
const oxfmtBin = require.resolve('oxfmt/bin/oxfmt');
1819

20+
// This allows oxfmt to load vite.config.ts
21+
// For `vp check` and `vp fmt`, see `src/utils/constants.ts`
22+
process.env.VITE_PLUS_VERSION = pkg.version;
1923
await import(pathToFileURL(oxfmtBin).href);

packages/cli/bin/oxlint

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ if (!process.argv.includes('--lsp')) {
1313
import { createRequire } from 'node:module';
1414
import { dirname, join } from 'node:path';
1515
import { pathToFileURL } from 'node:url';
16+
import pkg from '../package.json' with { type: 'json' };
1617

1718
const require = createRequire(import.meta.url);
1819
const oxlintMainPath = require.resolve('oxlint');
1920
const oxlintBin = join(dirname(dirname(oxlintMainPath)), 'bin', 'oxlint');
2021

22+
// This allows oxlint to load vite.config.ts
23+
// For `vp check` and `vp lint`, see `src/utils/constants.ts`
24+
process.env.VITE_PLUS_VERSION = pkg.version;
2125
await import(pathToFileURL(oxlintBin).href);

packages/cli/src/utils/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@ export const DEFAULT_ENVS = {
2929
JS_RUNTIME_NAME: process.release.name,
3030
// Indicate that vite-plus is the package manager
3131
NODE_PACKAGE_MANAGER: 'vite-plus',
32+
// This allows oxlint/oxfmt to load vite.config.ts
33+
// For `--lsp` path, see `bin/oxlint` and `bin/oxfmt`
34+
VITE_PLUS_VERSION,
3235
} as const;

0 commit comments

Comments
 (0)