Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ npx vale
## Why

Because the ones who know, know.

## Advanced

If you need to use a different binary than the pre-installed one (ie: the package doesn't support your system), you can specify a custom one like so:

```bash
VALE_BIN="/path/to/vale" npx vale
```
48 changes: 36 additions & 12 deletions src/vale.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
#!/usr/bin/env node
import { spawnSync } from "node:child_process";
import { outputBin } from "./shared";
import { existsSync } from "fs-extra";
if (existsSync(outputBin)) {
const result = spawnSync(outputBin, process.argv.slice(2), {
stdio: "inherit",
});
if (result.signal) {
console.error(`Process failed with signal: ${result.signal}`);
import { outputBin } from "./shared";

function resolveBin(): string {
const { VALE_BIN } = process.env;

if (VALE_BIN) {
if (existsSync(VALE_BIN)) {
return VALE_BIN;
}
console.error(
`VALE_BIN variable was specified but the path could not be found. Tried binary: ${VALE_BIN}`,
);
process.exit(1)
}
if (result.error) {
console.error(`Failed to run Vale, process exited with error: ${result.error.message}`)

if (!existsSync(outputBin)) {
console.error("Missing Vale binary. Did you run the postinstall?");
process.exit(1);
}
process.exit(result.status ?? 1);

return outputBin;
}

const bin = resolveBin();

const result = spawnSync(bin, process.argv.slice(2), {
stdio: "inherit",
});

if (result.signal) {
console.error(`Process failed with signal: ${result.signal}`);
}
if (result.error) {
console.error(
`Failed to run Vale, process exited with error: ${result.error.message}`,
);
}
console.error("Missing Vale binary. Did you run the postinstall?");
process.exit(1);

process.exit(result.status ?? 1);