Skip to content

Commit 7b8a55f

Browse files
author
Robert Masen
committed
Add nightly to commands
1 parent 06160a1 commit 7b8a55f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/build.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ pub fn rustup_add_wasm_target() -> Result<(), Error> {
1111
emoji::TARGET
1212
);
1313
let pb = PBAR.message(&step);
14+
ensure_nightly()?;
1415
let output = Command::new("rustup")
1516
.arg("target")
1617
.arg("add")
1718
.arg("wasm32-unknown-unknown")
19+
.arg("--toolchain")
20+
.arg("nightly")
1821
.output()?;
1922
pb.finish();
2023
if !output.status.success() {
@@ -25,6 +28,22 @@ pub fn rustup_add_wasm_target() -> Result<(), Error> {
2528
}
2629
}
2730

31+
fn ensure_nightly() -> Result<(), Error> {
32+
let nightly_check = Command::new("rustc").arg("+nightly").arg("-V").output()?;
33+
if !nightly_check.status.success() {
34+
let res = Command::new("rustup")
35+
.arg("toolchain")
36+
.arg("install")
37+
.arg("nightly")
38+
.output()?;
39+
if !res.status.success() {
40+
let s = String::from_utf8_lossy(&res.stderr);
41+
return Error::cli("Adding the nightly toolchain failed", s);
42+
}
43+
}
44+
Ok(())
45+
}
46+
2847
pub fn cargo_build_wasm(path: &str, debug: bool) -> Result<(), Error> {
2948
let step = format!(
3049
"{} {}Compiling to WASM...",
@@ -34,7 +53,7 @@ pub fn cargo_build_wasm(path: &str, debug: bool) -> Result<(), Error> {
3453
let pb = PBAR.message(&step);
3554
let output = {
3655
let mut cmd = Command::new("cargo");
37-
cmd.current_dir(path).arg("build");
56+
cmd.current_dir(path).arg("+nightly").arg("build");
3857
if !debug {
3958
cmd.arg("--release");
4059
}

src/emoji.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ pub static WARN: Emoji = Emoji("⚠️ ", ":-)");
1212
pub static DANCERS: Emoji = Emoji("👯 ", "");
1313
pub static ERROR: Emoji = Emoji("⛔ ", "");
1414
pub static INFO: Emoji = Emoji("ℹ️ ", "");
15+
pub static WRENCH: Emoji = Emoji("🔧 ", "");

0 commit comments

Comments
 (0)