Skip to content

Commit 5a2e494

Browse files
committed
fix: 🚑 allowed env var specification of command paths in building/serving
Before, they were only used in preparation.
1 parent 1d8d895 commit 5a2e494

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

‎packages/perseus-cli/src/build.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::errors::*;
33
use console::{style, Emoji};
44
use std::fs;
55
use std::path::PathBuf;
6+
use std::env;
67

78
// Emojis for stages
89
static GENERATING: Emoji<'_, '_> = Emoji("🔨", "");
@@ -27,7 +28,9 @@ pub fn build_internal(dir: PathBuf, num_steps: u8) -> Result<i32> {
2728

2829
// Static generation
2930
handle_exit_code!(run_stage(
30-
vec!["cargo run"],
31+
vec![
32+
&format!("{} run", env::var("PERSEUS_CARGO_PATH").unwrap_or_else(|_| "cargo".to_string()))
33+
],
3134
&target,
3235
format!(
3336
"{} {} Generating your app",
@@ -37,7 +40,9 @@ pub fn build_internal(dir: PathBuf, num_steps: u8) -> Result<i32> {
3740
)?);
3841
// WASM building
3942
handle_exit_code!(run_stage(
40-
vec!["wasm-pack build --target web"],
43+
vec![
44+
&format!("{} build --target web", env::var("PERSEUS_WASM_PACK_PATH").unwrap_or_else(|_| "wasm-pack".to_string()))
45+
],
4146
&target,
4247
format!(
4348
"{} {} Building your app to WASM",
@@ -58,7 +63,9 @@ pub fn build_internal(dir: PathBuf, num_steps: u8) -> Result<i32> {
5863
}
5964
// JS bundle generation
6065
handle_exit_code!(run_stage(
61-
vec!["rollup main.js --format iife --file dist/pkg/bundle.js"],
66+
vec![
67+
&format!("{} main.js --format iife --file dist/pkg/bundle.js", env::var("PERSEUS_ROLLUP_PATH").unwrap_or_else(|_| "rollup".to_string()))
68+
],
6269
&target,
6370
format!(
6471
"{} {} Finalizing bundle",

‎packages/perseus-cli/src/serve.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ fn serve_internal(dir: PathBuf, did_build: bool) -> Result<i32> {
3636
// Build the server runner
3737
// We use the JSON message format so we can get extra info about the generated executable
3838
let (stdout, _stderr) = handle_exit_code!(run_stage(
39-
vec!["cargo build --message-format json"],
39+
vec![
40+
&format!("{} build --message-format json", env::var("PERSEUS_CARGO_PATH").unwrap_or_else(|_| "cargo".to_string()))
41+
],
4042
&target,
4143
format!(
4244
"{} {} Building server",

0 commit comments

Comments
 (0)