Skip to content

Commit

Permalink
Preinstall pnpm on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Sep 10, 2024
1 parent 14a0b40 commit 2873fdd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup for Windows
if: matrix.os == 'windows-latest'
uses: pnpm/action-setup@v4
with:
version: 9.9
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: Cross-compile
Expand Down
17 changes: 3 additions & 14 deletions crates/depot/src/commands/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::{
};

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

Expand All @@ -33,16 +32,6 @@ 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 @@ -62,11 +51,11 @@ impl GlobalConfig {
root.display()
);

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

let pnpm_path = bindir.join(pnpm_bin());
let pnpm_path = bindir.join("pnpm");
if !pnpm_path.exists() {
println!("Downloading pnpm from Github...");
download_pnpm(&pnpm_path).await?;
Expand Down
1 change: 0 additions & 1 deletion crates/depot/src/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use self::{
use crate::{commands::setup::GlobalConfig, shareable, utils, CommonArgs};

use anyhow::{ensure, Context, Result};
use cfg_if::cfg_if;
use futures::{
stream::{self, TryStreamExt},
StreamExt,
Expand Down

0 comments on commit 2873fdd

Please sign in to comment.