Skip to content

Commit e24a146

Browse files
committed
refactor(yarn2): Move the logic for isProject to Locator
Prepare for an upcoming change. Signed-off-by: Frank Viernau <[email protected]>
1 parent ecf6a28 commit e24a146

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

plugins/package-managers/node/src/main/kotlin/yarn2/Yarn2DependencyHandler.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ internal class Yarn2DependencyHandler(
8181
}
8282
}
8383

84-
internal val PackageInfo.isProject: Boolean get() = value.substringAfterLast("@").startsWith("workspace:")
84+
internal val PackageInfo.isProject: Boolean get() = Locator.parse(value).isProject()
8585

8686
internal val PackageInfo.moduleName: String get() =
8787
// TODO: Handle patched packages different than non-patched ones.
@@ -111,4 +111,6 @@ internal data class Locator(
111111
)
112112
}
113113
}
114+
115+
fun isProject(): Boolean = remainder.startsWith("workspace:")
114116
}

plugins/package-managers/node/src/test/kotlin/yarn2/Yarn2DependencyHandlerTest.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,12 @@ class Yarn2DependencyHandlerTest : WordSpec({
4141
locator.remainder shouldBe "workspace:packages/spark"
4242
}
4343
}
44+
45+
"Locator.isProject()" should {
46+
"work for a workspace package" {
47+
val locator = Locator.parse("@failing/package-with-lightningcss@workspace:packages/spark")
48+
49+
locator.isProject() shouldBe true
50+
}
51+
}
4452
})

0 commit comments

Comments
 (0)