Skip to content

Commit

Permalink
breaking: Rename task type to platform. (#378)
Browse files Browse the repository at this point in the history
* Rename to platform.

* Update tests and docs.

* Rename token.

* Add new token.

* Update blog post.
  • Loading branch information
milesj committed Oct 20, 2022
1 parent 3e4355e commit daf3b1b
Show file tree
Hide file tree
Showing 26 changed files with 263 additions and 183 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ tasks:
command:
- eslint
- .
type: node
platform: node
lint-fix:
command:
- moon
- run
- common:lint
- --
- --fix
type: node
platform: node

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ tasks:
- ./lib
outputs:
- lib
type: node
platform: node
test:
command: jest
type: node
platform: node

3 changes: 1 addition & 2 deletions crates/config/src/project/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ pub struct TaskConfig {
pub options: TaskOptionsConfig,

#[serde(skip_serializing_if = "skip_if_default")]
#[serde(rename = "type")]
pub type_of: PlatformType,
pub platform: PlatformType,
}

impl TaskConfig {
Expand Down
6 changes: 3 additions & 3 deletions crates/config/templates/global_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ tasks:
# To output files to the workspace root, prefix the path with a "/".
outputs: []

# The type of command to run, and where to locate it.
# Accepts "node" (default) or "system".
type: 'node'
# The platform to run the command on, and where to locate it.
# Accepts "node" or "system". Defaults based on project `language`.
platform: 'node'
6 changes: 3 additions & 3 deletions crates/config/tests/tasks_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,18 +539,18 @@ outputs:
}
}

mod type_of {
mod platform {
#[test]
#[should_panic(
expected = "unknown variant: found `whatisthis`, expected `one of `node`, `system`, `unknown`` for key \"default.type\""
expected = "unknown variant: found `whatisthis`, expected `one of `node`, `system`, `unknown`` for key \"default.platform\""
)]
fn invalid_type() {
figment::Jail::expect_with(|jail| {
jail.create_file(
super::CONFIG_FILENAME,
r#"
command: foo
type: whatisthis
platform: whatisthis
"#,
)?;

Expand Down
4 changes: 2 additions & 2 deletions crates/platform-node/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub fn create_task(
}

if is_wrapping {
task_config.type_of = PlatformType::Node;
task_config.platform = PlatformType::Node;
task_config.command = Some(TaskCommandArgs::Sequence(string_vec![
"moon",
"node",
Expand All @@ -190,7 +190,7 @@ pub fn create_task(
args.insert(0, "noop".to_owned());
}

task_config.type_of = detect_platform_type(&args[0]);
task_config.platform = detect_platform_type(&args[0]);
task_config.command = Some(if args.len() == 1 {
TaskCommandArgs::String(args.remove(0))
} else {
Expand Down
Loading

0 comments on commit daf3b1b

Please sign in to comment.