diff --git a/always-rebuild.do b/always-rebuild.do new file mode 100644 index 0000000..06fcfe0 --- /dev/null +++ b/always-rebuild.do @@ -0,0 +1,2 @@ +redo-always +redo-ifchange release diff --git a/release.do b/release.do new file mode 100644 index 0000000..8ce97db --- /dev/null +++ b/release.do @@ -0,0 +1,4 @@ +redo-ifchange Cargo.toml +find src/ -type f | xargs redo-ifchange + +cargo build --release diff --git a/src/main.rs b/src/main.rs index cdb9fd2..072b70e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -446,10 +446,21 @@ globalThis.runOnInput = function(data) { // now. Another way to do this would be with an Arc. This will panic if the // mailbox is currently borrowed match mailbox.replace(None) { - Some(Ok(output)) => { - io::stdout() - .write_all(&output) - .map_err(|io_err| CompilerError::WriteOutputFailed(io_err, "stdout".into()))?; + Some(Ok(buffer)) => { + match output { + None => { + io::stdout() + .write_all(&buffer) + .map_err(|io_err| CompilerError::WriteOutputFailed(io_err, "stdout".into()))?; + }, + Some(filename) => { + let mut f = fs::File::create(&filename) + .map_err(|io_err| CompilerError::WriteOutputFailed(io_err, filename))?; + + f.write_all(&buffer) + .map_err(|io_err| CompilerError::WriteOutputFailed(io_err, "stdout".into()))?; + } + } } Some(Err(problem)) => { println!("had a problem {}", problem); diff --git a/starmelon-binary.do b/starmelon-binary.do new file mode 100644 index 0000000..43a6053 --- /dev/null +++ b/starmelon-binary.do @@ -0,0 +1,7 @@ +if test -f ../../target/debug/gen-css-selectors; then + redo-ifchange always-rebuild + ls -al ../../../target/release/starmelon | redo-stamp +else; + cargo build --release + ls -al ../../../target/release/starmelon | redo-stamp +fi