Commit bb0f097
authored
feat: add vite_command crate for command execution (#296)
### TL;DR
Add a new `vite_command` crate for executing commands with file system access tracking.
### What changed?
- Created a new `vite_command` crate that provides utilities for running commands with file system access tracking using `fspy`
- Added JavaScript bindings to expose this functionality to the CLI
- Implemented `runCommand()` function that can be imported from `@voidzero-dev/vite-plus/binding`
- Updated CI workflow to run the new tests
- Fixed stdio streams on Unix platforms to prevent issues with file descriptors
### How to test?
1. Run the new tests:
```
pnpm --filter=@voidzero-dev/vite-plus test
```
2. Try using the new API in JavaScript:
```js
import { runCommand } from '@voidzero-dev/vite-plus/binding';
const result = await runCommand({
binName: 'node',
args: ['-e', 'console.log("Hello, world!")'],
envs: { PATH: process.env.PATH },
cwd: process.cwd(),
});
console.log(`Exit code: ${result.exitCode}`);
console.log(`Path accesses:`, result.pathAccesses);
```
### Why make this change?
This change provides a robust way to track file system accesses made by child processes, which is essential for features like dependency tracking, caching, and build optimization. By exposing this functionality through JavaScript bindings, it enables the CLI to implement more intelligent build tools that can understand exactly which files are being read or written during command execution.1 parent 9d300ba commit bb0f097
19 files changed
Lines changed: 707 additions & 17 deletions
File tree
- .github/workflows
- crates/vite_command
- src
- packages
- cli
- binding
- __tests__
- __snapshots__
- src
- tools/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments