Skip to content

Commit

Permalink
feat: added publish: false in generated Cargo.toml to avoid accidenta…
Browse files Browse the repository at this point in the history
…l cargo publish (#358)
  • Loading branch information
christos-h authored Oct 17, 2022
1 parent c2d7fcc commit 2d67c6b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cargo-shuttle/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,16 @@ pub fn cargo_shuttle_init(path: PathBuf, framework: Box<dyn ShuttleInit>) -> Res
// Create an empty `[lib]` table
cargo_doc["lib"] = Item::Table(Table::new());

// Add publish: false to avoid accidental `cargo publish`
cargo_doc["package"]["publish"] = value(false);

// Create `[dependencies]` table
let mut dependencies = Table::new();

// Set "shuttle-service" version to `[dependencies]` table
let manifest_path = find(Some(path.as_path())).unwrap();
let url = registry_url(manifest_path.as_path(), None).expect("Could not find registry URL");

set_inline_table_dependency_version(
"shuttle-service",
&mut dependencies,
Expand All @@ -589,6 +593,7 @@ pub fn cargo_shuttle_init(path: PathBuf, framework: Box<dyn ShuttleInit>) -> Res

// Truncate Cargo.toml and write the updated `Document` to it
let mut cargo_toml = File::create(cargo_toml_path)?;

cargo_doc["dependencies"] = Item::Table(dependencies);
cargo_toml.write_all(cargo_doc.to_string().as_bytes())?;

Expand Down

0 comments on commit 2d67c6b

Please sign in to comment.