https://pantsbuild.org/ logo
#development
Title
# development
a

aloof-angle-91616

05/10/2020, 12:41 AM
for the code:
Copy code
fn fetch_cargo_packages(context: Context, args: Vec<Value>) -> NodeFuture<Value> {
  let lockfile_contents: String = externs::project_str(&args[0], "contents");
  let cargo_home_dir: String = context
    .core
    .cargo_fetcher
    .download_dir
    .to_str()
    .unwrap()
    .to_string();

  let core = context.core.clone();
  Box::pin(async move {
    let _krates: Vec<_> = core
      .cargo_fetcher
      .fetch_packages(&lockfile_contents)
      .await?;
    Ok(externs::unsafe_call(
      &core.types.construct_fetched_cargo_packages,
      &[externs::store_utf8(&cargo_home_dir)],
    ))
  })
  .compat()
  .to_boxed()
  .map_err(|e: cargo_utils::CargoMetadataError| throw(&format!("{:?}", e)))
  .to_boxed()
}