Develop #1
No files matched your search
+4
-2
@@ -9,10 +9,12 @@ pub fn run(name: &str, template_url: Option<&str>) -> std::io::Result<()> {
|
|||||||
return Err(Error::new(ErrorKind::AlreadyExists,
|
return Err(Error::new(ErrorKind::AlreadyExists,
|
||||||
format!("'{name}' already exists")));
|
format!("'{name}' already exists")));
|
||||||
}
|
}
|
||||||
std::fs::create_dir_all(dest)?;
|
|
||||||
|
|
||||||
match template_url {
|
match template_url {
|
||||||
None => template::write_starter(dest, name)?,
|
None => {
|
||||||
|
std::fs::create_dir_all(dest)?;
|
||||||
|
template::write_starter(dest, name)?;
|
||||||
|
}
|
||||||
Some(_) => return Err(Error::new(ErrorKind::Unsupported,
|
Some(_) => return Err(Error::new(ErrorKind::Unsupported,
|
||||||
"--template-url not implemented yet")),
|
"--template-url not implemented yet")),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ use std::path::Path;
|
|||||||
|
|
||||||
pub static STARTER: Dir = include_dir!("$CARGO_MANIFEST_DIR/template/starter");
|
pub static STARTER: Dir = include_dir!("$CARGO_MANIFEST_DIR/template/starter");
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn write_starter(dest: &Path, project_name: &str) -> std::io::Result<()> {
|
pub fn write_starter(dest: &Path, project_name: &str) -> std::io::Result<()> {
|
||||||
write_dir(&STARTER, dest, project_name)
|
write_dir(&STARTER, dest, project_name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,3 +20,12 @@ fn new_refuses_existing_dir() {
|
|||||||
.current_dir(d.path())
|
.current_dir(d.path())
|
||||||
.args(["new", "taken"]).assert().failure();
|
.args(["new", "taken"]).assert().failure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn new_with_template_url_stub_leaves_no_dir() {
|
||||||
|
let d = tempdir().unwrap();
|
||||||
|
Command::cargo_bin("matcha").unwrap()
|
||||||
|
.current_dir(d.path())
|
||||||
|
.args(["new", "demo", "--template-url", "gh:x/y"]).assert().failure();
|
||||||
|
assert!(!d.path().join("demo").exists());
|
||||||
|
}
|
||||||
Reference in new issue
Block a user