Skip to content

Commit

Permalink
feat: add license field (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Aug 16, 2024
1 parent d0b43b6 commit 25931e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/deno_json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ pub struct ConfigFileJson {
pub exclude: Option<Value>,
pub node_modules_dir: Option<bool>,
pub vendor: Option<bool>,
pub license: Option<Value>,
pub publish: Option<Value>,

pub name: Option<String>,
Expand Down Expand Up @@ -1294,6 +1295,15 @@ impl ConfigFile {
}
}

pub fn to_license(&self) -> Option<String> {
self.json.license.as_ref().and_then(|value| match value {
Value::String(license) if !license.trim().is_empty() => {
Some(license.trim().to_string())
}
_ => None,
})
}

/// Return any tasks that are defined in the configuration file as a sequence
/// of JSON objects providing the name of the task and the arguments of the
/// task in a detail field.
Expand Down
3 changes: 3 additions & 0 deletions src/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub struct JsrPackageConfig {
pub name: String,
pub member_dir: WorkspaceDirectory,
pub config_file: ConfigFileRc,
pub license: Option<String>,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -424,6 +425,7 @@ impl Workspace {
member_dir: self.resolve_member_dir(&c.specifier),
name: c.json.name.clone()?,
config_file: c.clone(),
license: c.to_license(),
})
})
}
Expand Down Expand Up @@ -1229,6 +1231,7 @@ impl WorkspaceDirectory {
name: pkg_name.clone(),
config_file: deno_json.clone(),
member_dir: self.clone(),
license: deno_json.to_license(),
})
}

Expand Down

0 comments on commit 25931e6

Please sign in to comment.