Skip to content

Commit

Permalink
pnpm.exe?
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Sep 10, 2024
1 parent 2873fdd commit 1bf28b0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions crates/depot/src/commands/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::{
};

use anyhow::{bail, ensure, Context, Result};
use cfg_if::cfg_if;
use futures::StreamExt;
use indicatif::{ProgressBar, ProgressStyle};

Expand All @@ -32,6 +33,16 @@ pub struct GlobalConfig {

const HOME_ENV_VAR: &str = "DEPOT_HOME";

fn pnpm_bin() -> &'static str {
cfg_if! {
if #[cfg(unix)] {
"pnpm"
} else {
"pnpm.exe"
}
}
}

impl GlobalConfig {
fn find_root() -> Result<PathBuf> {
match env::var(HOME_ENV_VAR) {
Expand All @@ -51,11 +62,11 @@ impl GlobalConfig {
root.display()
);

let pnpm_in_root = root.join("bin").join("pnpm");
let pnpm_in_root = root.join("bin").join(pnpm_bin());
let pnpm_path = if pnpm_in_root.exists() {
pnpm_in_root
} else {
let pnpm_fs_opt = pathsearch::find_executable_in_path("pnpm");
let pnpm_fs_opt = pathsearch::find_executable_in_path(pnpm_bin());
match pnpm_fs_opt {
Some(path) => path,
None => bail!("pnpm is not installed"),
Expand Down Expand Up @@ -146,7 +157,7 @@ impl SetupCommand {
let bindir = config.root.join("bin");
utils::create_dir_if_missing(&bindir)?;

let pnpm_path = bindir.join("pnpm");
let pnpm_path = bindir.join(pnpm_bin());
if !pnpm_path.exists() {
println!("Downloading pnpm from Github...");
download_pnpm(&pnpm_path).await?;
Expand Down

0 comments on commit 1bf28b0

Please sign in to comment.