Add feature flag for updating the manifest

This commit is contained in:
raychu86 2020-09-13 18:02:47 -07:00
parent 2a82a760f6
commit 515dc8204b
3 changed files with 14 additions and 5 deletions

View File

@ -150,8 +150,9 @@ version = "0.5"
version = "0.11.2"
[features]
default = [ ]
default = [ "update_manifest" ]
ci_skip = [ "leo-compiler/ci_skip" ]
update_manifest = [ "leo-package/update_manifest" ]
[profile.release]
opt-level = 3

View File

@ -41,3 +41,7 @@ version = "0.5"
[dev-dependencies.lazy_static]
version = "1.3.0"
[features]
default = [ ]
update_manifest = [ ]

View File

@ -183,11 +183,15 @@ author = "{author}"
}
// Rewrite the toml file if it has been updated
#[cfg(feature = "update_manifest")]
{
if buffer != new_toml {
let mut file = File::create(&path).map_err(|error| ManifestError::Creating(MANIFEST_FILENAME, error))?;
let mut file =
File::create(&path).map_err(|error| ManifestError::Creating(MANIFEST_FILENAME, error))?;
file.write_all(new_toml.as_bytes())
.map_err(|error| ManifestError::Writing(MANIFEST_FILENAME, error))?;
}
}
// Read the toml file
Ok(toml::from_str(&new_toml).map_err(|error| ManifestError::Parsing(MANIFEST_FILENAME, error))?)