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/resolver.rs b/packages/cli/binding/src/cli/resolver.rs index 98ffe1e526..043f5c8e82 100644 --- a/packages/cli/binding/src/cli/resolver.rs +++ b/packages/cli/binding/src/cli/resolver.rs @@ -103,7 +103,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 } => { @@ -138,7 +138,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 } => {