Skip to content

Commit

Permalink
fix(gen): swap to which for windows (#5208)
Browse files Browse the repository at this point in the history
  • Loading branch information
tknickman committed Jun 5, 2023
1 parent 2a45231 commit 0354e50
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crates/turborepo-lib/src/commands/generate.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
use std::process::{Command, Stdio};

use anyhow::Result;
use anyhow::{Context, Result};
use tracing::debug;
use which::which;

use crate::{
child::spawn_child,
cli::{GenerateCommand, GeneratorCustomArgs},
};

fn verify_requirements() -> Result<()> {
let output = Command::new("npx")
// find npx path
let npx = which("npx").context("Unable to run generate - missing requirements (npx)")?;

// make sure we can call npx
let output = Command::new(npx)
.arg("--version")
.stdout(Stdio::null())
.stderr(Stdio::null())
.status();

match output {
Ok(result) if result.success() => Ok(()),
_ => Err(anyhow::anyhow!(
"Unable to run generate - missing requirements (npx)"
)),
_ => Err(anyhow::anyhow!("Unable to run generate - cannot call npx")),
}
}

Expand Down

0 comments on commit 0354e50

Please sign in to comment.