Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(task): dependencies #129

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/deno_json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,18 +453,25 @@ pub struct WorkspaceConfig {
#[error("Failed to parse \"patch\" configuration.")]
pub struct PatchConfigParseError(#[source] serde_json::Error);

#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct TaskDefinition {
pub command: String,
#[serde(default)]
pub dependencies: Vec<String>,
}

#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Task {
Definition(String),
Definition(TaskDefinition),
Commented {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're at it, I think we maybe should consider dropping support for jsdocs for tasks? We can add description field to the object notation instead. I don't think we ever documented it besides the blog post

definition: String,
definition: TaskDefinition,
comments: Vec<String>,
},
}

impl Task {
pub fn definition(&self) -> &str {
pub fn definition(&self) -> &TaskDefinition {
match self {
Task::Definition(d) => d,
Task::Commented { definition, .. } => definition,
Expand Down
3 changes: 2 additions & 1 deletion src/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use crate::deno_json::ParsedTsConfigOptions;
use crate::deno_json::PatchConfigParseError;
use crate::deno_json::PublishConfig;
use crate::deno_json::Task;
use crate::deno_json::TaskDefinition;
use crate::deno_json::TestConfig;
use crate::deno_json::TsConfigForEmit;
use crate::deno_json::TsConfigType;
Expand Down Expand Up @@ -1656,7 +1657,7 @@ impl WorkspaceDirectory {

pub enum TaskOrScript<'a> {
/// A task from a deno.json.
Task(&'a IndexMap<String, Task>, &'a str),
Task(&'a IndexMap<String, Task>, &'a TaskDefinition),
/// A script from a package.json.
Script(&'a IndexMap<String, String>, &'a str),
}
Expand Down
Loading