be aware of license-file field as source of license

'license-file' field is provided in Cargo.toml for providing path of
license file.

https://doc.rust-lang.org/cargo/reference/manifest.html
master
rhysd 6 years ago
parent fee93bc965
commit 9fa5139caf
  1. 13
      src/license.rs
  2. 5
      src/manifest/mod.rs

@ -57,8 +57,8 @@ pub fn copy_from_crate(
"crate's pkg directory should exist"
);
match crate_data.crate_license() {
Some(_) => {
match (crate_data.crate_license(), crate_data.crate_license_file()) {
(Some(_), _) => {
let msg = format!("{}Copying over your LICENSE...", emoji::DANCERS);
PBAR.step(step, &msg);
let license_files = glob_license_files(path);
@ -80,7 +80,14 @@ pub fn copy_from_crate(
Err(_) => PBAR.info("origin crate has no LICENSE"),
}
}
None => {
(None, Some(license_file)) => {
let crate_license_path = path.join(&license_file);
let new_license_path = out_dir.join(&license_file);
if fs::copy(&crate_license_path, &new_license_path).is_err() {
PBAR.info("origin crate has no LICENSE");
}
}
(None, None) => {
PBAR.step(step, "No LICENSE found in Cargo.toml, skipping...");
}
};

@ -350,6 +350,11 @@ impl CrateData {
&self.manifest.package.license
}
/// Get the license file path for the crate at the given path.
pub fn crate_license_file(&self) -> &Option<String> {
&self.manifest.package.license_file
}
/// Returns the path to this project's target directory where artifacts are
/// located after a cargo build.
pub fn target_directory(&self) -> &Path {

Loading…
Cancel
Save