Skip to content

Commit b8477ea

Browse files
committed
Fixes an issue with scoped packages in additionalPackages option
1 parent 864498e commit b8477ea

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

.changeset/afraid-sheep-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Fixes an issue with scoped packages in additionalPackages option

packages/cli-v3/src/utilities/installPackages.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,34 @@ export function stripWorkspaceFromVersion(version: string) {
5555
}
5656

5757
export function parsePackageName(packageSpecifier: string): { name: string; version?: string } {
58-
const parts = packageSpecifier.split("@");
58+
let name: string | undefined;
59+
let version: string | undefined;
5960

60-
if (parts.length === 1 && typeof parts[0] === "string") {
61-
return { name: parts[0] };
61+
// Check if the package is scoped
62+
if (packageSpecifier.startsWith("@")) {
63+
const atIndex = packageSpecifier.indexOf("@", 1);
64+
// If a version is included
65+
if (atIndex !== -1) {
66+
name = packageSpecifier.slice(0, atIndex);
67+
version = packageSpecifier.slice(atIndex + 1);
68+
} else {
69+
name = packageSpecifier;
70+
}
71+
} else {
72+
const [packageName, packageVersion] = packageSpecifier.split("@");
73+
74+
if (typeof packageName === "string") {
75+
name = packageName;
76+
}
77+
78+
version = packageVersion;
6279
}
6380

64-
if (parts.length === 2 && typeof parts[0] === "string" && typeof parts[1] === "string") {
65-
return { name: parts[0], version: parts[1] };
81+
if (!name) {
82+
return { name: packageSpecifier };
6683
}
6784

68-
return { name: packageSpecifier };
85+
return { name, version };
6986
}
7087

7188
async function setPackageJsonDeps(path: string, deps: Record<string, string>) {

0 commit comments

Comments
 (0)