Skip to content

Commit e0593b9

Browse files
authored
fix: make sure to check std is taken from sway-lib-std folder (#5819)
## Description This PR adds a ad-hoc solution for #5811. Basically checks if the fetched package is 'std' and if so, only package from 'sway-lib-std' folder is accepted for that package.
1 parent a72d664 commit e0593b9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

forc-pkg/src/manifest/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,8 @@ impl std::ops::Deref for WorkspaceManifestFile {
992992
///
993993
/// Returns the path to the package on success, or `None` in the case it could not be found.
994994
pub fn find_within(dir: &Path, pkg_name: &str) -> Option<PathBuf> {
995+
use sway_types::constants::STD;
996+
const SWAY_STD_FOLDER: &str = "sway-lib-std";
995997
walkdir::WalkDir::new(dir)
996998
.into_iter()
997999
.filter_map(|entry| {
@@ -1002,7 +1004,13 @@ pub fn find_within(dir: &Path, pkg_name: &str) -> Option<PathBuf> {
10021004
.find_map(|entry| {
10031005
let path = entry.path();
10041006
let manifest = PackageManifest::from_file(path).ok()?;
1005-
if manifest.project.name == pkg_name {
1007+
// If the package is STD, make sure it is coming from correct folder.
1008+
if (manifest.project.name == pkg_name && pkg_name != STD)
1009+
|| (manifest.project.name == STD
1010+
&& path
1011+
.components()
1012+
.any(|comp| comp.as_os_str() == SWAY_STD_FOLDER))
1013+
{
10061014
Some(path.to_path_buf())
10071015
} else {
10081016
None

0 commit comments

Comments
 (0)