Bump subprocess and toml. Also remove the demo project I accidentally
pushed.
This commit is contained in:
@@ -12,12 +12,12 @@ publish.workspace = true
|
||||
[dependencies]
|
||||
derive_more.workspace = true
|
||||
fs.workspace = true
|
||||
io.workspace = true
|
||||
java.workspace = true
|
||||
pathsub.workspace = true
|
||||
semver.workspace = true
|
||||
serde.workspace = true
|
||||
sha256.workspace = true
|
||||
subprocess.workspace = true
|
||||
toml.workspace = true
|
||||
|
||||
[dependencies.anyhow]
|
||||
|
||||
@@ -5,16 +5,13 @@ pub type Result<T> = std::result::Result<T, Error>;
|
||||
#[derive(Debug, From, Display)]
|
||||
pub enum Error {
|
||||
#[from]
|
||||
Io(io::Error),
|
||||
Io(std::io::Error),
|
||||
|
||||
#[from]
|
||||
Java(java::Error),
|
||||
|
||||
MissingFileName,
|
||||
|
||||
#[from]
|
||||
StdIo(std::io::Error),
|
||||
|
||||
#[from]
|
||||
TomlDeserialize(toml::de::Error),
|
||||
|
||||
|
||||
@@ -2,11 +2,12 @@ use std::collections::HashMap;
|
||||
use std::fs::{OpenOptions, read_dir};
|
||||
use std::io::{Read, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
|
||||
use fs::expand_files;
|
||||
use io::run_process;
|
||||
use java::{JAVA_EXT_CLASS, JAVA_EXT_SOURCE};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use subprocess::Exec;
|
||||
|
||||
use crate::Error;
|
||||
use crate::nest::{F_NEST_LOCK, F_NEST_TOML, Nest, NestLock};
|
||||
@@ -102,7 +103,11 @@ impl WorkspaceHandler {
|
||||
self.write_example_project()?;
|
||||
self.discover_packages()?;
|
||||
|
||||
run_process(&["git", "init", "."])?;
|
||||
Exec::cmd("git")
|
||||
.arg("init")
|
||||
.arg(".")
|
||||
.start()?
|
||||
.wait_timeout(Duration::from_secs(10))?;
|
||||
}
|
||||
|
||||
// Append to .gitignore
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
[package]
|
||||
name = "io"
|
||||
version = "0.2.0"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
description = "Raven's IO utilities"
|
||||
repository.workspace = true
|
||||
|
||||
publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
derive_more.workspace = true
|
||||
subprocess.workspace = true
|
||||
@@ -1,11 +0,0 @@
|
||||
use derive_more::{Display, From};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, From, Display)]
|
||||
pub enum Error {
|
||||
#[from]
|
||||
Io(std::io::Error),
|
||||
#[from]
|
||||
Popen(subprocess::PopenError),
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
mod error;
|
||||
|
||||
use std::ffi;
|
||||
|
||||
pub use error::{Error, Result};
|
||||
|
||||
pub fn run_process<S>(argv: &[S]) -> Result<(Option<String>, Option<String>)>
|
||||
where
|
||||
S: AsRef<ffi::OsStr>,
|
||||
{
|
||||
let mut process = subprocess::Popen::create(
|
||||
argv,
|
||||
subprocess::PopenConfig {
|
||||
stdout: subprocess::Redirection::Pipe,
|
||||
..Default::default()
|
||||
},
|
||||
)?;
|
||||
|
||||
let result = process.communicate(None)?;
|
||||
|
||||
if process
|
||||
.wait_timeout(std::time::Duration::from_secs(5))
|
||||
.is_err()
|
||||
|| process.exit_status().is_none()
|
||||
{
|
||||
process.terminate()?;
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
@@ -16,5 +16,5 @@ publish.workspace = true
|
||||
bytesize.workspace = true
|
||||
derive_more.workspace = true
|
||||
fs.workspace = true
|
||||
io.workspace = true
|
||||
semver.workspace = true
|
||||
subprocess.workspace = true
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use subprocess::Exec;
|
||||
use subprocess::Redirection;
|
||||
|
||||
use crate::JAVA_BIN_COMPILER;
|
||||
use crate::Result;
|
||||
|
||||
@@ -45,6 +48,7 @@ pub struct Compiler {
|
||||
}
|
||||
|
||||
impl Compiler {
|
||||
/*
|
||||
pub fn compile<P: AsRef<Path>>(self, path: P) -> Result<(Option<String>, Option<String>)> {
|
||||
let mut cmd: Vec<String> = vec![JAVA_BIN_COMPILER.to_string()];
|
||||
|
||||
@@ -62,6 +66,23 @@ impl Compiler {
|
||||
|
||||
Ok(io::run_process(cmd.as_slice())?)
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn compile<P: AsRef<Path>>(self, path: P) -> Result<bool> {
|
||||
Ok(Exec::cmd(JAVA_BIN_COMPILER)
|
||||
.args(
|
||||
self.flags
|
||||
.clone()
|
||||
.into_iter()
|
||||
.flat_map(|f| Into::<Vec<String>>::into(f)),
|
||||
)
|
||||
.arg(path.as_ref())
|
||||
.stdout(Redirection::Pipe)
|
||||
.detached()
|
||||
.start()?
|
||||
.wait()?
|
||||
.success())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -7,13 +7,10 @@ pub enum Error {
|
||||
EmptyStdout,
|
||||
|
||||
#[from]
|
||||
Io(io::Error),
|
||||
Io(std::io::Error),
|
||||
|
||||
NthOutOfBounds,
|
||||
|
||||
#[from]
|
||||
Semver(semver::Error),
|
||||
|
||||
#[from]
|
||||
StdIo(std::io::Error),
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use std::str::FromStr;
|
||||
|
||||
pub use error::{Error, Result};
|
||||
use runtime::VMFlag;
|
||||
use subprocess::Exec;
|
||||
|
||||
pub const JAVA_BIN_VM: &str = "java";
|
||||
pub const JAVA_BIN_COMPILER: &str = "javac";
|
||||
@@ -41,9 +42,8 @@ pub fn get_javac_ver() -> Result<semver::Version> {
|
||||
|
||||
/// Calls the java binary, returning the complete stdout version information.
|
||||
fn get_java_version_info() -> Result<String> {
|
||||
Ok(
|
||||
io::run_process(&[JAVA_BIN_VM, VMFlag::Version.to_string().as_str()])?
|
||||
.0
|
||||
.ok_or(Error::EmptyStdout)?,
|
||||
)
|
||||
Ok(Exec::cmd(JAVA_BIN_VM)
|
||||
.arg(VMFlag::Version.to_string().as_str())
|
||||
.capture()?
|
||||
.stdout_str())
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use crate::JAVA_BIN_VM;
|
||||
use crate::Result;
|
||||
|
||||
use bytesize::ByteSize;
|
||||
use subprocess::Exec;
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct JVMBuilder {
|
||||
@@ -74,36 +75,32 @@ pub struct JVM {
|
||||
}
|
||||
|
||||
impl JVM {
|
||||
pub fn run<P: AsRef<Path>>(self, entry_point: P) -> Result<(Option<String>, Option<String>)> {
|
||||
let mut cmd = vec![JAVA_BIN_VM.to_string()];
|
||||
pub fn run<P: AsRef<Path>>(self, entry_point: P) -> Result<()> {
|
||||
let capture = Exec::cmd(JAVA_BIN_VM)
|
||||
.args(
|
||||
self.flags
|
||||
.clone()
|
||||
.into_iter()
|
||||
.flat_map(|f| Into::<Vec<String>>::into(f)),
|
||||
)
|
||||
.arg(entry_point.as_ref())
|
||||
.capture()?;
|
||||
|
||||
cmd.extend(
|
||||
self.flags
|
||||
.clone()
|
||||
.into_iter()
|
||||
.flat_map(|f| Into::<Vec<String>>::into(f)),
|
||||
);
|
||||
|
||||
cmd.push(entry_point.as_ref().to_path_buf().display().to_string());
|
||||
|
||||
let result = io::run_process(cmd.as_slice())?;
|
||||
|
||||
if self.monitor {
|
||||
let (stdout, stderr) = &result;
|
||||
|
||||
if let Option::Some(stdout) = stdout
|
||||
&& stdout.len() > 0
|
||||
{
|
||||
print!("{stdout}");
|
||||
}
|
||||
if let Option::Some(stderr) = stderr
|
||||
&& stderr.len() > 0
|
||||
{
|
||||
eprintln!("{stderr}");
|
||||
}
|
||||
if !self.monitor {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
let stdout = capture.stdout_str();
|
||||
if stdout.len() > 0 {
|
||||
println!("{stdout}");
|
||||
}
|
||||
|
||||
let stderr = capture.stderr_str();
|
||||
if stderr.len() > 0 {
|
||||
eprintln!("{stderr}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,5 @@ bytesize.workspace = true
|
||||
cli.workspace = true
|
||||
core.workspace = true
|
||||
fs.workspace = true
|
||||
io.workspace = true
|
||||
java.workspace = true
|
||||
toml.workspace = true
|
||||
|
||||
@@ -17,7 +17,6 @@ fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
.map_err(|err| anyhow!(err))?;
|
||||
|
||||
dbg!();
|
||||
match &CLI_ARGS.command {
|
||||
Command::New { .. } | Command::Init => wh.init(),
|
||||
Command::Build => wh.build(),
|
||||
|
||||
Reference in New Issue
Block a user