Skip to content

Commit bd0e949

Browse files
committed
fix(cli,bin): Add env.VP_VERSION for oxlint and oxfmt (#946)
Fixes #939
1 parent 18f9f50 commit bd0e949

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

packages/cli/bin/oxfmt

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 oxfmtMainPath = require.resolve('oxfmt');
1920
const oxfmtBin = join(dirname(dirname(oxfmtMainPath)), 'bin', 'oxfmt');
2021

22+
// This allows oxfmt to load vite.config.ts
23+
// For `vp check` and `vp fmt`, it is injected by `merge_resolved_envs_with_version()` in `cli.rs`
24+
process.env.VP_VERSION = pkg.version;
2125
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`, it is injected by `merge_resolved_envs_with_version()` in `cli.rs`
24+
process.env.VP_VERSION = pkg.version;
2125
await import(pathToFileURL(oxlintBin).href);

packages/cli/binding/src/cli/resolver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl SubcommandResolver {
103103
untracked_env: None,
104104
input: None,
105105
}),
106-
envs: merge_resolved_envs(envs, resolved.envs),
106+
envs: merge_resolved_envs_with_version(envs, resolved.envs),
107107
})
108108
}
109109
SynthesizableSubcommand::Fmt { mut args } => {
@@ -138,7 +138,7 @@ impl SubcommandResolver {
138138
untracked_env: None,
139139
input: None,
140140
}),
141-
envs: merge_resolved_envs(envs, resolved.envs),
141+
envs: merge_resolved_envs_with_version(envs, resolved.envs),
142142
})
143143
}
144144
SynthesizableSubcommand::Build { args } => {

0 commit comments

Comments
 (0)