From 1a15ffc16145b5d46f343e26e9c22de0edbb58e0 Mon Sep 17 00:00:00 2001 From: Yuji Sugiura Date: Mon, 16 Mar 2026 16:06:59 +0900 Subject: [PATCH] fix(cli,editor): Add env.VITE_PLUS_VERSION for oxlint and oxfmt --- packages/cli/bin/oxfmt | 4 ++++ packages/cli/bin/oxlint | 4 ++++ packages/cli/binding/src/cli.rs | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/cli/bin/oxfmt b/packages/cli/bin/oxfmt index 6a0a68c568..63624504bf 100755 --- a/packages/cli/bin/oxfmt +++ b/packages/cli/bin/oxfmt @@ -13,9 +13,13 @@ if (!process.argv.includes('--lsp')) { import { createRequire } from 'node:module'; import { dirname, join } from 'node:path'; import { pathToFileURL } from 'node:url'; +import pkg from '../package.json' with { type: 'json' }; const require = createRequire(import.meta.url); const oxfmtMainPath = require.resolve('oxfmt'); const oxfmtBin = join(dirname(dirname(oxfmtMainPath)), 'bin', 'oxfmt'); +// This allows oxfmt to load vite.config.ts +// For `vp check` and `vp fmt`, it is injected by `merge_resolved_envs_with_version()` in `cli.rs` +process.env.VP_VERSION = pkg.version; await import(pathToFileURL(oxfmtBin).href); diff --git a/packages/cli/bin/oxlint b/packages/cli/bin/oxlint index 2385020e74..4d5824c1c9 100755 --- a/packages/cli/bin/oxlint +++ b/packages/cli/bin/oxlint @@ -13,9 +13,13 @@ if (!process.argv.includes('--lsp')) { import { createRequire } from 'node:module'; import { dirname, join } from 'node:path'; import { pathToFileURL } from 'node:url'; +import pkg from '../package.json' with { type: 'json' }; const require = createRequire(import.meta.url); const oxlintMainPath = require.resolve('oxlint'); const oxlintBin = join(dirname(dirname(oxlintMainPath)), 'bin', 'oxlint'); +// This allows oxlint to load vite.config.ts +// For `vp check` and `vp lint`, it is injected by `merge_resolved_envs_with_version()` in `cli.rs` +process.env.VP_VERSION = pkg.version; await import(pathToFileURL(oxlintBin).href); diff --git a/packages/cli/binding/src/cli.rs b/packages/cli/binding/src/cli.rs index 7dd66bf906..def170e9db 100644 --- a/packages/cli/binding/src/cli.rs +++ b/packages/cli/binding/src/cli.rs @@ -271,7 +271,7 @@ impl SubcommandResolver { untracked_env: None, input: None, }), - envs: merge_resolved_envs(envs, resolved.envs), + envs: merge_resolved_envs_with_version(envs, resolved.envs), }) } SynthesizableSubcommand::Fmt { mut args } => { @@ -309,7 +309,7 @@ impl SubcommandResolver { untracked_env: None, input: None, }), - envs: merge_resolved_envs(envs, resolved.envs), + envs: merge_resolved_envs_with_version(envs, resolved.envs), }) } SynthesizableSubcommand::Build { args } => {