-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: honour handleTransparentWorkspaces setting in Yarn/Berry
- Loading branch information
1 parent
ffe5be9
commit 7cb26de
Showing
4 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use std::io; | ||
|
||
use serde::Deserialize; | ||
use serde_yaml; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum Error { | ||
#[error("encountered error parsing yarnrc.yml: {0}")] | ||
SerdeYaml(#[from] serde_yaml::Error), | ||
} | ||
|
||
/// A yarnrc.yaml file representing settings affecting the package graph. | ||
#[allow(non_snake_case)] | ||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize)] | ||
pub struct YarnRc { | ||
/// Used by Yarn(Berry) as `enableTransparentWorkspaces`. | ||
/// When true, treats local workspaces that match a package name | ||
/// and semver range as correct match resulting in turbo including | ||
/// the package in the dependency graph | ||
pub enableTransparentWorkspaces: bool, | ||
} | ||
|
||
impl Default for YarnRc { | ||
fn default() -> YarnRc { | ||
YarnRc { | ||
enableTransparentWorkspaces: true, | ||
} | ||
} | ||
} | ||
|
||
impl YarnRc { | ||
pub fn from_reader(mut reader: impl io::Read) -> Result<Self, Error> { | ||
let config: YarnRc = serde_yaml::from_reader(&mut reader)?; | ||
Ok(config) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_parse_empty_yarnrc() { | ||
let empty = YarnRc::from_reader(b"".as_slice()).unwrap(); | ||
assert_eq!( | ||
empty, | ||
YarnRc { | ||
enableTransparentWorkspaces: true | ||
} | ||
); | ||
} | ||
|
||
#[test] | ||
fn test_parses_transparent_workspaces() { | ||
let empty = YarnRc::from_reader(b"enableTransparentWorkspaces: false".as_slice()).unwrap(); | ||
assert_eq!( | ||
empty, | ||
YarnRc { | ||
enableTransparentWorkspaces: false | ||
} | ||
); | ||
} | ||
} |