Write to .crates.toml

This commit is contained in:
Félix Saparelli 2022-07-04 23:53:47 +12:00
parent caf6f3930b
commit 1c2d005fd4
No known key found for this signature in database
GPG key ID: B948C4BAE44FC474
6 changed files with 207 additions and 2 deletions

View file

@ -201,7 +201,10 @@ async fn entry() -> Result<()> {
// Initialize REQWESTGLOBALCONFIG
REQWESTGLOBALCONFIG
.set(ReqwestConfig { secure: opts.secure, min_tls: opts.min_tls_version.map(|v| v.into()) })
.set(ReqwestConfig {
secure: opts.secure,
min_tls: opts.min_tls_version.map(|v| v.into()),
})
.unwrap();
// Setup logging
@ -451,6 +454,21 @@ async fn install_from_package(
uithread.confirm().await?;
debug!("Writing .crates.toml");
if let Ok(mut ctoml) = metafiles::CratesToml::load().await {
ctoml.insert(
metafiles::CrateVersionSource {
name: opts.name.into(),
version: package.version.parse().into_diagnostic()?,
source: metafiles::Source::Registry(
url::Url::parse("https://github.com/rust-lang/crates.io-index").unwrap(),
),
},
bin_files.iter().map(|bin| bin.base_name.clone()),
);
ctoml.write().await?;
}
info!("Installing binaries...");
block_in_place(|| {
for file in &bin_files {